diff options
| author | amankumarsingh77 <amankumarsingh7702@gmal.com> | 2026-05-08 00:18:15 +0530 |
|---|---|---|
| committer | amankumarsingh77 <amankumarsingh7702@gmal.com> | 2026-05-08 00:18:15 +0530 |
| commit | aa08e740cb2f12cb424a2d042619955c99230ed7 (patch) | |
| tree | 20c983aa38aaa34a61cb6f5aa273d153cb0df18a /src/prompt.ts | |
| parent | 4052e6e6afef1dc20146765963dea7c0289ca401 (diff) | |
feat: add per-tab isolation for multi-agent safety
Replace singleton dialog, pageInfoDirty, networkBuffer, and consoleBuffer
with per-tab TabSession objects stored in a Map<string, TabSession>.
- Add TabSession type (sessionId, targetId, dialog, pageInfoDirty,
networkBuffer, consoleBuffer) and tabs/sessionIdToTargetId Maps
- Add ev.sessionId filter guard in consumeEvents to prevent cross-tab
event contamination
- Rework switchTo to create/reuse TabSession without clearing buffers,
updating sessionId on re-attach
- Route all CDP events (dialog, network, console) through resolveTab
to the correct TabSession
- takeDialog/drainPageInfoInvalidations/drainNetworkBuffer/
drainConsoleBuffer read from current TabSession
- Target.targetDestroyed prunes dead TabSession entries
- attachFirstPage creates initial TabSession and prunes dead entries
- Per-tab pageCaches Map in client.ts replaces pageCache singleton
- listTabs reconciliation prunes dead pageCaches entries
- console-buffer.ts clear() resets nextSeq to 1 (per-tab seq space)
- Multi-agent warning in prompt.ts Parallel Execution section
Diffstat (limited to 'src/prompt.ts')
| -rw-r--r-- | src/prompt.ts | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/prompt.ts b/src/prompt.ts index 850d36f..ae94db3 100644 --- a/src/prompt.ts +++ b/src/prompt.ts @@ -74,6 +74,8 @@ browser_screenshot() + browser_page_info() + browser_execute_js("document.title" browser_http_get("https://api.example.com/data") + browser_click(x, y) \`\`\` +**Multi-agent note**: When multiple subagents use the browser, tab switching by one agent changes the active tab for all agents. Per-tab data (console buffers, network traces, dialogs, page info cache) is isolated — switching tabs does not destroy another agent's collected data. Call \`browser_current_tab\` before mutation tools to confirm you're on the expected tab. If \`browser_page_info\` returns a dialog, handle it with \`browser_handle_dialog\` promptly — dialogs block page interaction and are not queued across agents. + ### Common Patterns **Navigation:** |
