Skip to content

examples/browser-use-cua: duplicate imports, Tools() instantiation, and __main__ block #180

@Ricardo-M-L

Description

@Ricardo-M-L

Description

`examples/browser-use-cua/main.py` has three duplicated top-level sections:

  1. Imports — `asyncio`, `base64`, `os`, and `io.BytesIO` are each imported twice in the first 14 lines
  2. Tools instantiation — `tools = Tools()` appears at both line ~39 and line ~277. The second one overwrites the first binding, so any `@tools.registry.action(...)` decorator attached between them is discarded
  3. Main block — the file ends with two consecutive `if name == "main": asyncio.run(main())` blocks, so `main()` actually runs twice sequentially

Impact

Only (2) and (3) affect behavior. In the current code the registrations happen after the second `tools = Tools()`, so no action is lost — but the redeclaration pattern is fragile: any future refactor that moves a decorator upward would silently break. (3) causes the demo to run end-to-end twice, which is visible in the console output but easy to miss.

Fix

Collapse imports to one block, remove the second `tools = Tools()`, remove the second `main` block. PR forthcoming.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions