Skip to content

fix(browser): create CDP targets in background - #82482

Open
Ramadas108 wants to merge 1 commit into
NousResearch:mainfrom
Ramadas108:fix/browser-cdp-background-targets
Open

fix(browser): create CDP targets in background#82482
Ramadas108 wants to merge 1 commit into
NousResearch:mainfrom
Ramadas108:fix/browser-cdp-background-targets

Conversation

@Ramadas108

Copy link
Copy Markdown

Problem

Hermes can drive an already-running Chrome over CDP (an attached or residential-IP browser, e.g. 127.0.0.1:9222). In two paths the CDP layer creates a page target:

  1. CDPSupervisor._attach_initial_page() — when no page target exists yet, the supervisor creates one.
  2. the raw browser_cdp tool — an agent escape hatch that forwards arbitrary CDP methods.

Target.createTarget without background: true activates the new tab and raises the browser window, stealing desktop focus from the operator while agents work in the browser. For an attached everyday browser this is disruptive: the user's window pops to the foreground mid-task.

Fix

  • tools/browser_cdp_tool.py: Target.createTarget params are forced to background: true, so the escape hatch cannot forget it.
  • tools/browser_supervisor.py: initial page creation passes background: true.

No change to the existing browser workflow — tabs created this way simply never raise the window.

Tests

tests/tools/test_browser_background_tab.py — regression tests for both paths (supervisor _attach_initial_page and the raw browser_cdp tool), asserting the background flag is always present.

Validation

Verified against a real attached Chrome over CDP (127.0.0.1:9222): Target.createTarget succeeds with the background flag, the window is not raised, and the created target closes cleanly.

When Hermes drives an already-running Chrome via CDP, Target.createTarget
without background:true activates the new tab and raises the browser window,
stealing desktop focus from the operator while agents work in the browser.

Force background:true in the CDP supervisor initial-page creation and in the
raw browser_cdp tool so target creation never raises the user's window,
without changing the existing browser workflow.

Includes regression tests for both the supervisor and the raw tool paths.
@alt-glitch alt-glitch added type/bug Something isn't working tool/browser Browser automation (CDP, Playwright) P3 Low — cosmetic, nice to have labels Aug 9, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

Related to #80335: this focused patch carries its browser-CDP background-target fix without that PR's unrelated compatibility changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P3 Low — cosmetic, nice to have tool/browser Browser automation (CDP, Playwright) type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants