Skip to content

[Bugfix] Fix local Chrome CDP attach validation - #12968

Draft
HiddenPuppy wants to merge 2 commits into
NousResearch:mainfrom
HiddenPuppy:codex/fix-issue-12912-browser-connect
Draft

[Bugfix] Fix local Chrome CDP attach validation#12968
HiddenPuppy wants to merge 2 commits into
NousResearch:mainfrom
HiddenPuppy:codex/fix-issue-12912-browser-connect

Conversation

@HiddenPuppy

Copy link
Copy Markdown
Contributor

Summary

  • fall back to DevToolsActivePort when local Chrome exposes a debug port but /json/version is unavailable
  • make /browser connect validate the resolved CDP endpoint before reporting success
  • store the resolved websocket endpoint so later browser/CDP tools use the same concrete URL

Root cause

Recent Chrome built-in remote debugging flows can leave port 9222 open and write a real browser websocket to DevToolsActivePort while returning 404 from classic discovery endpoints like /json/version. Hermes treated a listening port as success and relied too heavily on /json/version, so /browser connect could report success even though later CDP usage still failed.

Validation

  • source .venv-ci/bin/activate && python -m pytest tests/tools/test_browser_cdp_override.py tests/tools/test_browser_cdp_tool.py tests/tools/test_browser_cloud_fallback.py tests/cli/test_cli_browser_connect.py -q
    • 40 passed
  • source .venv-ci/bin/activate && python -m pytest tests/ -q -n 0
    • interrupted after surfacing unrelated pre-existing failures in tests/gateway/*, tests/hermes_cli/test_gateway_wsl.py, tests/hermes_cli/test_gemini_provider.py, and tests/run_agent/test_*interrupt*

@HiddenPuppy HiddenPuppy changed the title [codex] Fix local Chrome CDP attach validation [Bugfix] Fix local Chrome CDP attach validation Apr 20, 2026
@HiddenPuppy

Copy link
Copy Markdown
Contributor Author

Hi Hermes team @teknium1 , I’ve really enjoyed following the project and working with the codebase, and I’d love to become a contributor. I’m interested in helping with bug fixes, testing, documentation, and small feature improvements, and I’m happy to start with issues that are most useful to the project. I’d like to contribute consistently, learn the project’s standards, and gradually take on more responsibility over time.☺

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists tool/browser Browser automation (CDP, Playwright) labels Apr 22, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Likely duplicate of #12198 — both harden local Chrome CDP discovery to handle /json/version unavailability and validate actual CDP endpoint.

@teknium1 teknium1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for investigating the Chrome built-in remote-debugging path. The underlying compatibility gap remains on current main: tools/browser_tool.py:422433 returns the raw shorthand after discovery fails, and the CLI rejects the connection at hermes_cli/cli_commands_mixin.py:1847 and :1882:1886 before it can attach.

Problems

  • tools/browser_tool.py:269 on this PR reads parsed.port outside the exception handler. For an invalid port, urllib.parse raises ValueError, changing a failed CDP discovery into an uncaught resolver failure.
  • The patch does not cover the TUI browser.manage path, which independently probes only /json/version and /json in tui_gateway/server.py:13707:13708.
  • The second commit includes unrelated run_agent.py, tools/approval.py, model-catalog, and release-map changes. These should not travel with a CDP attach fix.

Suggested changes

  • Salvage the fallback into the current shared CLI/TUI connection flow, with tests for 404 + DevToolsActivePort on both surfaces.
  • Guard invalid parsed.port access and add the regression test.
  • Keep the browser fix scoped to browser files/tests.

This is an automated hermes-sweeper review.

Comment thread tools/browser_tool.py
return ""

host = parsed.hostname or ""
port = parsed.port

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

parsed.port can raise ValueError for a malformed port (for example, http://127.0.0.1:abc), but it is outside the surrounding try. Please catch that case and return the normal empty fallback so an invalid configured endpoint cannot turn discovery failure into an uncaught exception.

Comment thread run_agent.py
detector for local endpoints.
"""
cfg = get_provider_stale_timeout(self.provider, self.model)
cfg = get_provider_stale_timeout(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This stale-timeout change is unrelated to local Chrome CDP discovery. Please split it from this browser-focused PR so the CDP fix can be evaluated and salvaged independently.

@teknium1 teknium1 added sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:risk-platform-windows Sweeper risk: may break or behave differently on native Windows sweeper:blast-broad Sweeper blast radius: broad — a core path most sessions hit labels Jul 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Medium — degraded but workaround exists sweeper:blast-broad Sweeper blast radius: broad — a core path most sessions hit sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:risk-platform-windows Sweeper risk: may break or behave differently on native Windows sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state 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.

3 participants