You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 4f18aea
Browse filesBrowse the repository at this point in the historyBrowse files
[AI-assisted] docs(browser): teach the code-mode global call, not the removed tools.call API (#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 #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
Copy file name to clipboardExpand all lines: extensions/browser/skills/browser-automation/SKILL.md
+38-22Lines changed: 38 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -48,40 +48,56 @@ Use this skill when you need the `browser` tool for anything beyond a single pag
48
48
49
49
## Code Mode Loop
50
50
51
-
When `tools.codeMode` is enabled, call the Browser tool from exec cells:
51
+
When `tools.codeMode` is enabled, the Browser tool has no normal turn — it is cataloged behind `exec`/`wait`. Call it from exec cells as an async global, using the callable name the exec quick index advertises for the Browser tool (normally `browser`; colliding names get suffixed, and a client tool can win an identical name). An exact `catalog.search("browser")` returns a handle already bound to the effective callable name, so resolve the handle in each cell and call it instead of hard-coding the literal global; an empty result means the Browser tool is not cataloged in this run.
Keep the same labeled tab through the loop, and alternate reads with actions:
53
+
Keep the same labeled tab through the loop, and alternate reads with actions. Each `exec` cell starts a fresh VM — bindings from a completed cell are gone in the next, and only runs left `waiting` keep their state until `wait` resumes them — so carry comparison state across cells by returning it and re-embedding the returned values in the next cell:
60
54
61
55
```javascript
62
-
constsnapshotCall=awaitcallBrowser({
56
+
// previous = the url/newElements returned by the last completed cell (a fresh
57
+
// VM runs this cell, so prior bindings do not exist here).
- Code-mode calls return the tool's structured `details` directly (`targetId`, `url`, `newElements`, `stats`, `blockedByDialog`); rendered page text is not returned to code cells.
81
+
- To read text inside code mode, run a targeted `act` evaluate (requires the evaluate capability; `browser.evaluateEnabled` can disable it) and keep the returned value bounded, because page-script output is untrusted:
- Request interactive-only snapshots and filter them in code before returning.
80
-
- Return only the handful of relevant elements; never return the full tree.
81
-
- Keep `previousSnapshot` between cells when a local diff helps explain a change.
94
+
When evaluate is unavailable, keep the loop on structured state only.
95
+
96
+
- Return only the fields the next step needs; never return the whole details object.
97
+
- Completed cells share no state: re-embed the previous cell's returned `url`/`newElements` in the next cell, or keep the comparison inside one cell. Only `waiting` runs persist, resumed by `wait`.
82
98
- Interleave each act with a URL or tabs check before the next dependent act.
83
99
- If a batch returns `aborted`, take a fresh snapshot before continuing.
84
-
- If `[new]` markers appear, inspect those elements first, then update the saved snapshot.
100
+
- If `newElements` is positive, inspect those elements first, then update the re-embedded state.
85
101
- Use separate act calls when navigation is expected between steps.
0 commit comments