From c64934ee2c12c436c2f853cb4272a8301f392ba4 Mon Sep 17 00:00:00 2001 From: Alezander9 Date: Thu, 30 Apr 2026 00:05:54 -0700 Subject: [PATCH] fix(browser_execute): use real helper names in tool description The tool description listed `goto`, `click`, `screenshot` -- none of those exist. The actual helpers (per harness/src/browser_harness/helpers.py) are `goto_url`, `click_at_xy`, `capture_screenshot`. Agents followed the description literally and got NameError on every call. Also nudge agents toward `new_tab(url)` for first navigation per SKILL.md, since bare `goto_url` clobbers the user's active tab. Repro: fresh install, ask any model to "go to wikipedia". Pre-fix: NameError: name 'goto' is not defined. Post-fix: agent uses `new_tab("https://wikipedia.org")` directly. --- packages/opencode/src/tool/browser-execute.txt | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/packages/opencode/src/tool/browser-execute.txt b/packages/opencode/src/tool/browser-execute.txt index bbd92de98..08edbddf3 100644 --- a/packages/opencode/src/tool/browser-execute.txt +++ b/packages/opencode/src/tool/browser-execute.txt @@ -2,8 +2,9 @@ Execute Python code against a connected web browser via the BrowserCode harness. This is the single tool for all browser interaction. The agent writes Python that imperatively drives the browser using helpers preloaded into the script's namespace -(`goto`, `click`, `type_text`, `screenshot`, `js`, `cdp`, `new_tab`, `switch_tab`, -`wait_for_load`, `page_info`, `http_get`, etc.). +(`goto_url`, `click_at_xy`, `type_text`, `capture_screenshot`, `js`, `cdp`, +`new_tab`, `switch_tab`, `ensure_real_tab`, `wait_for_load`, `page_info`, +`http_get`, etc.). Read `packages/bcode-browser/harness/SKILL.md` for the full helper surface and recommended workflow. Read `packages/bcode-browser/harness/src/browser_harness/helpers.py` @@ -15,14 +16,17 @@ browser. Add task-specific helpers to `packages/bcode-browser/harness/agent-workspace/agent_helpers.py` between calls; they take effect on the very next call. -Coordinate-based interaction is the default — `click(x, y)` rather than selector -indices. `Input.dispatchMouseEvent` passes through iframes, shadow DOM, and -cross-origin at the compositor level. +Coordinate-based interaction is the default — `click_at_xy(x, y)` rather than +selector indices. `Input.dispatchMouseEvent` passes through iframes, shadow DOM, +and cross-origin at the compositor level. + +For first navigation use `new_tab(url)` (or `ensure_real_tab(); goto_url(url)`), +not bare `goto_url` — the latter clobbers whatever tab the user is on. Output is whatever the script writes to stdout/stderr. Wrap multi-step flows in one call when possible — that's the design. Example: - goto("https://example.com") + new_tab("https://example.com") wait_for_load() print(page_info())