Summary
The Pi agent_browser wrapper's implicit managed session can lose the selected tab between a successful open/snapshot -i and the very next action. The snapshot returns current refs for the intended page, but an immediate click @ref fails as stale-ref, and get url reports about:blank with a warning that the prior intended tab could not be re-selected.
This also makes semantic locators miss elements that were visible in the immediately preceding snapshot.
Environment
agent-browser CLI version: 0.31.1 (doctor: CLI version 0.31.1 (macos aarch64))
- Browser from
doctor: Brave Browser 149.1.91.180 at /Applications/Brave Browser.app/Contents/MacOS/Brave Browser
agent_browser doctor: pass:11, warn:0, fail:0
- Reproduced via the native Pi
agent_browser tool on 2026-07-06
Repro 1: local fixture refs go stale immediately
Fixture:
<!doctype html><meta charset="utf-8"><title>Agent Browser Smoke</title><label>Name <input id="name"></label><button id="go">Greet</button><p id="out">Ready</p><script>document.getElementById('go').onclick=()=>{document.getElementById('out').textContent='Hello '+document.getElementById('name').value}</script>
Steps run through Pi agent_browser:
{"args":["open","file:///tmp/agent-browser-smoke.html"],"sessionMode":"fresh","timeoutMs":60000}
Output:
Agent Browser Smoke
file:///tmp/agent-browser-smoke.html
{"args":["snapshot","-i"],"timeoutMs":30000}
Output:
Origin: file:///tmp/agent-browser-smoke.html
Refs: 2
- textbox "Name " [ref=e2]
- button "Greet" [ref=e1]
Immediate next call:
{"args":["click","@e1"],"timeoutMs":30000}
Actual output:
Unknown ref: e1
Agent-browser hint: This ref may be stale after navigation, scrolling, or re-rendering. Run `snapshot -i` again and retry with a current `@e…` ref; for less ref churn, use `find role|text|label|placeholder|alt|title|testid ...` or `scrollintoview` before interacting with off-screen elements.
Result category: failure; failureCategory: stale-ref; Pi tool isError: true.
Then:
{"args":["get","url"],"timeoutMs":30000}
Output:
Warning: agent_browser detected that this session returned about:blank while the prior intended tab was file:///tmp/agent-browser-smoke.html. No matching tab could be re-selected; run tab list for the same session or retry with sessionMode=fresh.
about:blank
Repro 2: semantic locator misses visible link after snapshot
{"args":["open","https://example.com/"],"sessionMode":"fresh","timeoutMs":60000}
Output:
Example Domain
https://example.com/
{"args":["snapshot","-i"],"timeoutMs":30000}
Output:
Origin: https://example.com/
Refs: 2
- heading "Example Domain" [level=1, ref=e1]
- link "Learn more" [ref=e2]
Immediate semantic action:
{"semanticAction":{"action":"click","locator":"role","role":"link","name":"Learn more"},"timeoutMs":30000}
Actual output:
Element not found. Verify the selector is correct and the element exists in the DOM.
Result category: failure; failureCategory: selector-not-found; Pi tool isError: true.
Then:
{"args":["get","url"],"timeoutMs":30000}
Output:
Warning: agent_browser detected that this session returned about:blank while the prior intended tab was https://example.com/ No matching tab could be re-selected; run tab list for the same session or retry with sessionMode=fresh.
about:blank
Expected
The default documented flow open → snapshot -i → click @ref should keep operating on the same page/tab. The immediate click @e1 should click the button, and the semantic role=link name="Learn more" action should find the link shown by the snapshot.
Actual
The implicit managed session appears to drift to about:blank between calls. Current snapshot refs are rejected as stale/unknown, and semantic locators miss visible elements.
Workaround that worked
Using an explicit named session kept the tab stable:
{"args":["--session","pi-smoke-issue-repro","open","file:///tmp/agent-browser-smoke.html"],"timeoutMs":60000}
{"args":["--session","pi-smoke-issue-repro","snapshot","-i"],"timeoutMs":30000}
{"args":["--session","pi-smoke-issue-repro","click","@e1"],"timeoutMs":30000}
Output from the final call:
Clicked: @e1
Current page:
Agent Browser Smoke
file:///tmp/agent-browser-smoke.html
Notes
A qa preset on https://example.com passed, and an explicit-session smoke with open → snapshot → fill/click/get text → semanticAction also passed. The failure seems specific to the implicit Pi-managed/default session target tracking, not basic browser launch or click support.
Summary
The Pi
agent_browserwrapper's implicit managed session can lose the selected tab between a successfulopen/snapshot -iand the very next action. The snapshot returns current refs for the intended page, but an immediateclick @reffails asstale-ref, andget urlreportsabout:blankwith a warning that the prior intended tab could not be re-selected.This also makes semantic locators miss elements that were visible in the immediately preceding snapshot.
Environment
agent-browserCLI version:0.31.1(doctor:CLI version 0.31.1 (macos aarch64))doctor: Brave Browser149.1.91.180at/Applications/Brave Browser.app/Contents/MacOS/Brave Browseragent_browser doctor:pass:11, warn:0, fail:0agent_browsertool on 2026-07-06Repro 1: local fixture refs go stale immediately
Fixture:
Steps run through Pi
agent_browser:{"args":["open","file:///tmp/agent-browser-smoke.html"],"sessionMode":"fresh","timeoutMs":60000}Output:
{"args":["snapshot","-i"],"timeoutMs":30000}Output:
Immediate next call:
{"args":["click","@e1"],"timeoutMs":30000}Actual output:
Then:
{"args":["get","url"],"timeoutMs":30000}Output:
Repro 2: semantic locator misses visible link after snapshot
{"args":["open","https://example.com/"],"sessionMode":"fresh","timeoutMs":60000}Output:
{"args":["snapshot","-i"],"timeoutMs":30000}Output:
Immediate semantic action:
{"semanticAction":{"action":"click","locator":"role","role":"link","name":"Learn more"},"timeoutMs":30000}Actual output:
Then:
{"args":["get","url"],"timeoutMs":30000}Output:
Expected
The default documented flow
open → snapshot -i → click @refshould keep operating on the same page/tab. The immediateclick @e1should click the button, and the semanticrole=link name="Learn more"action should find the link shown by the snapshot.Actual
The implicit managed session appears to drift to
about:blankbetween calls. Current snapshot refs are rejected as stale/unknown, and semantic locators miss visible elements.Workaround that worked
Using an explicit named session kept the tab stable:
{"args":["--session","pi-smoke-issue-repro","open","file:///tmp/agent-browser-smoke.html"],"timeoutMs":60000} {"args":["--session","pi-smoke-issue-repro","snapshot","-i"],"timeoutMs":30000} {"args":["--session","pi-smoke-issue-repro","click","@e1"],"timeoutMs":30000}Output from the final call:
Notes
A
qapreset onhttps://example.compassed, and an explicit-session smoke withopen → snapshot → fill/click/get text → semanticActionalso passed. The failure seems specific to the implicit Pi-managed/default session target tracking, not basic browser launch or click support.