hermes - 💡(How to fix) Fix [Bug]: browser_console crashes with CDP "Object reference chain is too long" when returning DOM Elements [1 pull requests]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Error Message

When the LLM uses the browser_console tool and its injected JavaScript returns a raw DOM Node or NodeList (e.g., return document.body), it causes a fatal CDP serialization crash instead of returning a graceful tool error. Proposed Fix: Update _browser_eval in tools/browser_tool.py to wrap the incoming expression in an IIFE that explicitly checks if the returned result is an instance of Node or Window. If it is, it should return a clean string like "TOOL_ERROR: Extract primitive values instead" to guide the LLM back on track. 3. Observe the output. Instead of getting a graceful TOOL_ERROR, the underlying CDP connection will crash completely, throwing a raw "Object reference chain is too long" exception back to the agent. When the LLM uses the browser_console tool and its injected JavaScript returns a raw DOM Node or NodeList (e.g., return document.body), it causes a fatal CDP serialization crash instead of returning a graceful tool error 3. Observe the output. Instead of getting a graceful TOOL_ERROR, the underlying CDP connection will crash completely, throwing a raw "Object reference chain is too long" exception back to the agent.

Additional Logs / Traceback (optional)

Root Cause

Root Cause Analysis (optional)

Fix Action

Fixed

Code Example

⚠️  This will upload the following to a public paste service:
System info (OS, Python version, Hermes version, provider, which API keys
    are configured — NOT the actual keys)
Recent log lines (agent.log, errors.log, gateway.log — may contain
    conversation fragments and file paths)
Full agent.log and gateway.log (up to 512 KB each — likely contains
    conversation content, tool outputs, and file paths)

Pastes auto-delete after 6 hours.

Collecting debug report...
Uploading...

Debug report uploaded:
  Report       https://paste.rs/rcrsx
  agent.log    https://paste.rs/kSPOw
  gateway.log  https://paste.rs/fwtnL

Pastes will auto-delete in 6 hours.
To delete now:  hermes debug delete <url>

---
RAW_BUFFERClick to expand / collapse

Bug Description

When the LLM uses the browser_console tool and its injected JavaScript returns a raw DOM Node or NodeList (e.g., return document.body), it causes a fatal CDP serialization crash instead of returning a graceful tool error. Proposed Fix: Update _browser_eval in tools/browser_tool.py to wrap the incoming expression in an IIFE that explicitly checks if the returned result is an instance of Node or Window. If it is, it should return a clean string like "TOOL_ERROR: Extract primitive values instead" to guide the LLM back on track. Proposed Fix (Tested Locally): In tools/browser_tool.py, update the _browser_eval function to wrap the incoming expression in an IIFE that safely checks the result before returning it to the CDP protocol: safe_expression = f""" (() => {{ const result = (function() {{ {expression} }})(); if (result instanceof Node || result instanceof NodeList || (typeof Window !== 'undefined' && result instanceof Window)) {{ return "TOOL_ERROR: You cannot return raw DOM Elements. Please extract and return primitive values like .innerText or .href instead."; }} return result; }})() """

Steps to Reproduce

. Start an active Hermes agent session with the browser tools enabled. 2. Tell the agent to run the following exact command: browser_console(expression="document.body") 3. Observe the output. Instead of getting a graceful TOOL_ERROR, the underlying CDP connection will crash completely, throwing a raw "Object reference chain is too long" exception back to the agent.

Expected Behavior

When the LLM uses the browser_console tool and its injected JavaScript returns a raw DOM Node or NodeList (e.g., return document.body), it causes a fatal CDP serialization crash instead of returning a graceful tool error

Actual Behavior

. Start an active Hermes agent session with the browser tools enabled. 2. Tell the agent to run the following exact command: browser_console(expression="document.body") 3. Observe the output. Instead of getting a graceful TOOL_ERROR, the underlying CDP connection will crash completely, throwing a raw "Object reference chain is too long" exception back to the agent.

Affected Component

Tools (terminal, file ops, web, code execution, etc.)

Messaging Platform (if gateway-related)

No response

Debug Report

⚠️  This will upload the following to a public paste service:
  • System info (OS, Python version, Hermes version, provider, which API keys
    are configured — NOT the actual keys)
  • Recent log lines (agent.log, errors.log, gateway.log — may contain
    conversation fragments and file paths)
  • Full agent.log and gateway.log (up to 512 KB each — likely contains
    conversation content, tool outputs, and file paths)

Pastes auto-delete after 6 hours.

Collecting debug report...
Uploading...

Debug report uploaded:
  Report       https://paste.rs/rcrsx
  agent.log    https://paste.rs/kSPOw
  gateway.log  https://paste.rs/fwtnL

⏱  Pastes will auto-delete in 6 hours.
To delete now:  hermes debug delete <url>

Operating System

Windows

Python Version

3.11

Hermes Version

0.15.0

Additional Logs / Traceback (optional)

Root Cause Analysis (optional)

No response

Proposed Fix (optional)

No response

Are you willing to submit a PR for this?

  • I'd like to fix this myself and submit a PR

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

hermes - 💡(How to fix) Fix [Bug]: browser_console crashes with CDP "Object reference chain is too long" when returning DOM Elements [1 pull requests]