Skip to content

fix(examples): deduplicate imports, Tools() instantiation, and __main__ block in browser-use-cua#181

Open
Ricardo-M-L wants to merge 1 commit into
agent-infra:mainfrom
Ricardo-M-L:fix/browser-use-cua-dedup
Open

fix(examples): deduplicate imports, Tools() instantiation, and __main__ block in browser-use-cua#181
Ricardo-M-L wants to merge 1 commit into
agent-infra:mainfrom
Ricardo-M-L:fix/browser-use-cua-dedup

Conversation

@Ricardo-M-L
Copy link
Copy Markdown

Summary

Fixes #180.

The browser-use-cua example had three sections copy-pasted twice: the imports block, the tools = Tools() instantiation, and the if __name__ == "__main__" entry point. The second tools = Tools() also overwrote the first binding, making any decorator attached between them silently dead code.

This PR collapses them to single occurrences each.

Behavioral changes

  • The example no longer runs main() twice on invocation (previously the two __main__ blocks executed sequentially).
  • No other functional change — the surviving tools binding is the one the rest of the file already uses.

Test plan

  • Ran python -m py_compile examples/browser-use-cua/main.py — passes
  • Confirmed tools = Tools() appears once and all @tools.registry.action(...) decorators fall after it

Related

Part of splitting closed PR #167. Previously opened: #171, #173, #175, #177, #179. This is the final bug (6 of 6).

🤖 Generated with Claude Code

…_main__ block in browser-use-cua

The browser-use-cua example had three duplicated sections at the top
level:

- Two sets of imports for \`asyncio\`, \`base64\`, \`os\`, and \`io.BytesIO\`
- Two \`tools = Tools()\` instantiations (the second overwrote the
  first, discarding any action registrations that referenced the
  original binding — harmless here only because the registration
  occurs after the second line)
- Two \`if __name__ == "__main__": asyncio.run(main())\` blocks at the
  bottom (the second runs main twice in a row)

Removed the redundant copies. This is a pure cleanup; behavior is
unchanged for normal happy-path runs, but the example no longer ships
with the second main() call that would have executed after the first
completed.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant