Repository navigation
[AI-assisted] docs(browser): teach the code-mode global call, not the removed tools.call API - #128456
Conversation
….call API The browser-automation skill's Code Mode Loop still taught the guest `tools.call(browserTool, input)` API that openclaw#126262 removed, together with the `.result.details`/`.result.content` envelope reads. Rewrite the loop for the current contract: call the `browser(...)` async global directly, receive the tool's structured details (targetId, url, newElements, stats, blockedByDialog), and diff url/new-element counts between cells instead of filtering snapshot text, since rendered page text is no longer guest-visible in code mode.
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs real behavior proof before merge. Reviewed August 25, 2026, 5:40 AM ET / 09:40 UTC. ClawSweeper reviewWhat this changesUpdates the Browser automation skill to use Code Mode’s callable catalog handles and structured Browser results instead of the removed Regression provenancePossible regression — probable (reviewed change; known regression link). No predecessor PR is attributed. Merge readinessNo blocking findings. This remains a useful, contract-aligned documentation repair for Browser use in OpenClaw Code Mode; the supplied PR proof is stronger than required for a docs-only change. Priority: P1 Review scores
Verification
How this fits togetherCode Mode compacts enabled tools behind flowchart LR
A[Browser automation skill] --> B[Code Mode exec cell]
B --> C[Run-scoped catalog]
C --> D[Resolved Browser handle]
D --> E[Browser extension]
E --> F[Structured details]
F --> B
Before merge
Agent review detailsSecurityNone. PR surfaceDocs +16. Total +16 across 1 file. View PR surface stats
Review metricsNone. Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Land the handle-based Browser Code Mode guidance so agents follow the canonical catalog and structured-result contracts without reviving the removed API. Do we have a high-confidence way to reproduce the issue? Yes—source shows the current guest contract uses callable globals or catalog handles and directly projects structured details, while the supplied pre-change documentation used the removed legacy envelope. Is this the best way to solve the issue? Yes—the update follows the canonical Code Mode prompt contract and avoids hard-coding a callable name that catalog collision handling may change. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 8e040714b305. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (5 earlier review cycles)
|
|
Independent landing verification for contributor head
|
|
Merged via squash.
|
… removed tools.call API (openclaw#128456) * docs(browser): teach the code-mode global call, not the removed tools.call API The browser-automation skill's Code Mode Loop still taught the guest `tools.call(browserTool, input)` API that openclaw#126262 removed, together with the `.result.details`/`.result.content` envelope reads. Rewrite the loop for the current contract: call the `browser(...)` async global directly, receive the tool's structured details (targetId, url, newElements, stats, blockedByDialog), and diff url/new-element counts between cells instead of filtering snapshot text, since rendered page text is no longer guest-visible in code mode. * docs(browser): resolve callable from quick index and read via targeted evaluate * docs(browser): call the search-resolved handle and carry cell state explicitly
What Problem This Solves
The browser-automation skill's Code Mode Loop still taught the guest to call the Browser tool via
tools.call("openclaw:browser:browser", input)and read the.result.details/.result.contentenvelope. That API was removed by #126262 (merged 2026-08-20, "improve(code-mode): call tools as global functions"); an agent following the skill verbatim in code mode fails on the first cell.The first revision of this fix still had two dead ends, caught in review: it told readers to take a "normal snapshot turn" to read the page (no such turn exists while code mode is active — the Browser tool is cataloged behind
exec/waitand the bridge strips snapshotcontent), and it hard-coded the callable namebrowser(the catalog can suffix colliding globals and lets a client tool win an identical name, so the run's quick index is the only authority).Root cause
The skill predates #126262. Code mode now exposes enabled tools as async global functions (
src/agents/code-mode.ts: "Enabled tools are async global functions listed in the quick index"), and the bridge returns the tool's structureddetailsdirectly —src/agents/code-mode-bridge.tscallValue:So
result.content(rendered page text) never reaches a code cell; onlydetailsdoes. Callable names are run-scoped:createCodeModeCatalogProjection(src/agents/code-mode-catalog.ts) suffixes colliding/reserved names (suffixedCallableName) andselectEffectiveEntrieslets a client tool win an exact-name collision, which is why the exec quick index (andcatalog.searchfallback) is the documented way to resolve a callable.Fix
Rewrite the loop for the current contract:
browser), falling back tocatalog.search("browser")when the index omits or renames it,details(targetId,url,newElements,stats,blockedByDialog— all present insafeDetailsfromextensions/browser/src/browser-tool.snapshot.ts),url/newElementsbetween cells instead of filtering snapshot text,actevaluate ({ action: "act", kind: "evaluate", fn, targetId }; the fn's value comes back indetails.result, andbrowser.evaluateEnabledcan disable it), keeping the returned value bounded — or stay on structured state only when evaluate is unavailable.Docs only; no code paths touched.
Evidence
Real Code Mode + Browser execution transcript (after-fix, head
4ef2e571)Ran on this branch with a harness that boots the real gateway with the real browser plugin (headless Chromium), resolves the real gateway-scoped tool surface, applies the real code-mode catalog compaction (
applyCodeModeCatalog, force-enabled like an engaged code-mode turn), and drives the realexectool with the three cells the revised skill teaches. The page is a loopback-only fixture (http://127.0.0.1:<port>/) — nothing to redact: no external URLs, keys, or credentials are involved. Transcript ends withPROOF-TRANSCRIPT-END; each cell'sexecresult came backstatus: "completed"with real catalog telemetry (callCount0 → 2 → 3 across cells).Cell 1 — callable discovery (quick-index global +
catalog.searchfallback):{ "status": "completed", "value": { "matches": ["browser"], "callable": "function", "globalName": "browser" }, "telemetry": { "catalogSize": 31, "searchCount": 1, "callCount": 0, "visibleTools": ["exec", "wait"] } }Cell 2 —
open+ structured snapshot loop (readingdetails, not snapshot text):{ "status": "completed", "value": { "targetId": "8EBD0393F324C2788760085803C7C99E", "url": "http://127.0.0.1:<port>/", "stats": { "lines": 2, "chars": 82, "refs": 2, "interactive": 2 }, "changed": true }, "telemetry": { "callCount": 2, "visibleTools": ["exec", "wait"] } }Cell 3 — bounded evaluate read (
act/kind: "evaluate", value inresult):{ "status": "completed", "value": { "url": "http://127.0.0.1:<port>/", "text": "Browser skill code-mode proof\n\nPROOF-PAGE-READY\n\nQuery Submit" }, "telemetry": { "callCount": 3, "visibleTools": ["exec", "wait"] } }This shows exactly what the fix teaches: the Browser callable resolves as the run-scoped
browserglobal (and viacatalog.search("browser")), the snapshot loop consumes structureddetails(targetId,url,stats— rendered page text never reaches the cell), and page text is read through a targeted boundedevaluatewhose value returns indetails.result.After-fix verification on this branch (node 22.23.2, fresh
pnpm install):node --import tsx scripts/test-projects.mts -- src/agents/code-mode.guest.test.ts— 21/21 passed, including "exposes catalog tools as bare globals and removes the legacy guest surface", "keeps normalized, reserved, and colliding prompt names aligned with runtime", "uses the client tool as the single winner for a shadowed exact name", and "returns structured values from globals and callable catalog handles" (globals return structureddetailsto code cells; callable names come from the runtime projection).formatBrowserExternalToolResult,extensions/browser/src/browser-tool.actions.ts) with an evaluate act payload{ ok: true, targetId: "task", url: "https://example.com/after-submit", result: "Submitted\nConfirmation #42" }returnsdetails = { ok, targetId, url, result }— the evaluate value reaches code cells viadetails.result— whilecontent[0].textis wrapped asEXTERNAL_UNTRUSTED_CONTENTand never returned to code cells.main,git grep "tools.call" extensions/browsermatches only this skill's stale example — every other reference in docs is a different surface (mcp.tools.call.v1node command, the Tool Searchopenclaw.tools.callbridge, cron migration history).mainsource: global name resolution (code-mode-catalog.ts), details shape (browser-tool.snapshot.tssafeDetails), act response contract ({ ok, targetId, url?, result? }fromclient-actions-core.ts/routes/agent.act.ts), evaluate gating (browser.evaluateEnabled,browser-tool.schema.ts).npx --yes [email protected] --check extensions/browser/skills/browser-automation/SKILL.mdpasses (repo-pinned version).Risks
Low — docs-only change to a skill file. The evaluate example assumes the evaluate capability is enabled (default); the doc says to fall back to structured state when it is not.