Skip to content

Commit a5f446d

Browse files
committed
docs(browser): call the search-resolved handle and carry cell state explicitly
1 parent 4ef2e57 commit a5f446d

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

  • extensions/browser/skills/browser-automation

‎extensions/browser/skills/browser-automation/SKILL.md‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,15 @@ Use this skill when you need the `browser` tool for anything beyond a single pag
4848

4949
## Code Mode Loop
5050

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). If the quick index omits or renames it, discover it with `catalog.search("browser")` and call the returned handle:
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.
5252

53-
```javascript
54-
let previous = { url: undefined, newElements: undefined };
55-
```
56-
57-
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:
5854

5955
```javascript
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).
58+
const previous = { url: "https://example.com/inbox", newElements: 0 };
59+
const [browser] = await catalog.search("browser", { limit: 1 });
6060
const details = await browser({
6161
action: "snapshot",
6262
snapshotFormat: "ai",
@@ -68,7 +68,6 @@ const changed =
6868
details?.url !== previous.url ||
6969
(details?.newElements ?? 0) > 0 ||
7070
details?.blockedByDialog === true;
71-
previous = { url: details?.url, newElements: details?.newElements };
7271
return {
7372
targetId: details?.targetId,
7473
url: details?.url,
@@ -82,6 +81,7 @@ return {
8281
- 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:
8382
8483
```javascript
84+
const [browser] = await catalog.search("browser", { limit: 1 });
8585
const read = await browser({
8686
action: "act",
8787
kind: "evaluate",
@@ -94,10 +94,10 @@ return { url: read?.url, text: read?.result };
9494
When evaluate is unavailable, keep the loop on structured state only.
9595
9696
- Return only the fields the next step needs; never return the whole details object.
97-
- Keep `previous` between cells when a url change or new-element count helps explain a change.
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`.
9898
- Interleave each act with a URL or tabs check before the next dependent act.
9999
- If a batch returns `aborted`, take a fresh snapshot before continuing.
100-
- If `newElements` is positive, inspect those elements first, then update the saved state.
100+
- If `newElements` is positive, inspect those elements first, then update the re-embedded state.
101101
- Use separate act calls when navigation is expected between steps.
102102
103103
## Tab Hygiene

0 commit comments

Comments
 (0)