fix(browser): pin shared CDP sessions to tabs - #86879
Conversation
Related: #83274 and #75597 address the same shared-CDP isolation outcome through different mechanisms (Hermes-side persistent/dedicated targets versus this agent-browser native named-session pinning). Maintainer selection or consolidation is needed; this is not a duplicate. |
fix(browser): pin shared CDP sessions to tabs A thorough, security-motivated change: per-task named sessions with
|
f9de232 to
13e3e90
Compare
|
The triage note above asks for maintainer selection among this PR, #83274,
Mechanism notes:
This PR's regression suite includes an explicit two-tasks-on-one-endpoint For transparency: this code has been running on a production Hermes Happy to rebase onto current |
af8bf37 to
0e84702
Compare
0e84702 to
22a0771
Compare
|
Rebased onto current main at 22a0771bdd (resolves the dirty state from the last few days of landings). Verification on the rebased head: 120 browser-tool tests passed across orphan-reaper / lifecycle-fail-closed / CDP-pinning / cleanup / CDP-override / agent-version suites; ruff, py_compile, Windows footgun checker, and diff-check clean. Two test adaptations were needed for changes that landed on main after our branch: the orphan reaper now requires a start-time fingerprint before terminating a daemon (tests mock Note on the Desktop E2E failure on this head: |
22a0771 to
8953184
Compare
8953184 to
b772a42
Compare
What does this PR do?
Prevents high-level browser tasks from hijacking each other when multiple Hermes tasks share one Chrome/CDP endpoint and profile.
agent-browsersession with--cdp --pin-tabtab_goneinstead of adopting another task's or user's pageabout:blanksessionWhy this approach?
agent-browser0.34 provides the missing low-level primitive: persistent named-session-to-target binding plus strict--pin-tab. Hermes owns the lifecycle, publication fencing, supervisor routing, and cleanup guarantees around that primitive rather than adding a second target broker or an endpoint-wide lock.The shared browser profile is still intentionally shared: cookies, storage, accounts, and rate limits are not isolated. The isolation boundary is page-target ownership.
Addresses the high-level browser path in #62338 and overlaps with the shared-CDP isolation work discussed in #83274, #75597, and #86924. This PR additionally covers Hermes high-level tool lifecycle, provider ownership, supervisor routing, exact-once eval behavior, cleanup/orphan handling, and idle continuity.
Runtime compatibility
agent-browser@0.26.0, compatible with Hermes' Node.js 22.22+ baselineagent-browser >=0.34.0agent-browser@0.34.0; npm's release-age override applies only to that exact acquisition, not future0.34.xreleasesTesting
Final local verification on commit
f9de232401:538 passed, 8 skippedacrosstests/tools/test_browser_*.py44 passedacross lifecycle, turn-finalizer, interrupt, and run-agent regression tests7 passedin managed runtime resolution tests (plus two pre-existingDeprecationWarnings)py_compile, andgit diff --checkpassReal isolated Chromium +
agent-browser 0.34.0acceptance covered:browser_session_retiredNode/runtime acquisition was also exercised with empty npm caches on the supported paths.
Scope
This intentionally does not add per-task ACLs to raw
browser_cdp. Raw CDP remains a privileged browser-wide escape hatch and can address a caller-supplied target directly. The page-ownership guarantees above apply to the high-levelbrowser_*task flow.