Summary
browser_get_images returns {"success": false, "error": "Evaluation error: SyntaxError: Unexpected end of input"} on real content pages. The same page is fine — a hand-written document.images query via browser_console works, and every other browser_* tool (navigate, snapshot, click, type, press, back, scroll, vision, console) works in the same session.
Repro
Fresh CLI session (Browserbase backend, no residential proxies, but that's incidental — bug reproduces on pages that don't touch bot-detection at all):
browser_navigate → https://en.wikipedia.org/wiki/Hermes (loads, title "Hermes - Wikipedia", 2023 elements in snapshot)
browser_get_images → fails
Output:
{"success": false, "error": "Evaluation error: SyntaxError: Unexpected end of input"}
Reproduced twice back-to-back on the same page. Also hit during an earlier ad-hoc browser-tool sweep (no other failing tool in the same run).
Workaround that succeeds on the same session/page — identical logic, wrapped in an IIFE and sent through browser_console:
(() => {
const imgs = Array.from(document.querySelectorAll('img')).slice(0, 5);
return imgs.map(i => ({src: i.src, alt: i.alt || '', w: i.naturalWidth, h: i.naturalHeight}));
})()
Returns the list cleanly.
Where the bug likely lives
tools/browser_tool.py line ~2722 (browser_get_images) builds this raw multi-line expression and ships it to _run_browser_command(task_id, "eval", [js_code]):
js_code = """JSON.stringify(
[...document.images].map(img => ({
src: img.src,
alt: img.alt || '',
width: img.naturalWidth,
height: img.naturalHeight
})).filter(img => img.src && !img.src.startsWith('data:'))
)"""
The same code wrapped in an IIFE via browser_console (which presumably routes through the same CDP eval underneath) succeeds, so the failure is in how the eval bridge wraps / parses this particular expression shape (leading JSON.stringify( + trailing ) over multi-line, no leading (...) grouping or return). SyntaxError: Unexpected end of input is the canonical error when an evaluator feeds the string into something that expects a complete statement/function body rather than a bare expression (e.g. new Function(body) without a return, or a wrapper that strips the closing paren).
Suggested fix
One of:
- Wrap the expression at the call site as an IIFE so it's unambiguous regardless of how the bridge parses it:
js_code = """(() => JSON.stringify(
[...document.images].map(img => ({ ... })).filter(...)
))()"""
- Or make
_run_browser_command(..., "eval", ...) always wrap single-expression inputs as (() => (<expr>))() before shipping to CDP.
(1) is the one-line fix. (2) prevents the same footgun from biting other eval callers.
Environment
- OS: Windows 10 (also presumably affects other OSes — the evaluator path is shared)
- Browser backend: Browserbase (hosted; warning emitted about no residential proxies, but that's unrelated — the failure is at the JS-parse stage before any page behavior matters)
- hermes-agent: latest
main as of 2026-05-08 (clone for inspection just now)
- Tool version path:
tools/browser_tool.py browser_get_images at ~L2705, schema at ~L1397, registry at ~L3488
Summary
browser_get_imagesreturns{"success": false, "error": "Evaluation error: SyntaxError: Unexpected end of input"}on real content pages. The same page is fine — a hand-writtendocument.imagesquery viabrowser_consoleworks, and every other browser_* tool (navigate, snapshot, click, type, press, back, scroll, vision, console) works in the same session.Repro
Fresh CLI session (Browserbase backend, no residential proxies, but that's incidental — bug reproduces on pages that don't touch bot-detection at all):
browser_navigate→ https://en.wikipedia.org/wiki/Hermes (loads, title "Hermes - Wikipedia", 2023 elements in snapshot)browser_get_images→ failsOutput:
{"success": false, "error": "Evaluation error: SyntaxError: Unexpected end of input"}Reproduced twice back-to-back on the same page. Also hit during an earlier ad-hoc browser-tool sweep (no other failing tool in the same run).
Workaround that succeeds on the same session/page — identical logic, wrapped in an IIFE and sent through
browser_console:Returns the list cleanly.
Where the bug likely lives
tools/browser_tool.pyline ~2722 (browser_get_images) builds this raw multi-line expression and ships it to_run_browser_command(task_id, "eval", [js_code]):The same code wrapped in an IIFE via
browser_console(which presumably routes through the same CDP eval underneath) succeeds, so the failure is in how the eval bridge wraps / parses this particular expression shape (leadingJSON.stringify(+ trailing)over multi-line, no leading(...)grouping orreturn).SyntaxError: Unexpected end of inputis the canonical error when an evaluator feeds the string into something that expects a complete statement/function body rather than a bare expression (e.g.new Function(body)without areturn, or a wrapper that strips the closing paren).Suggested fix
One of:
_run_browser_command(..., "eval", ...)always wrap single-expression inputs as(() => (<expr>))()before shipping to CDP.(1) is the one-line fix. (2) prevents the same footgun from biting other
evalcallers.Environment
mainas of 2026-05-08 (clone for inspection just now)tools/browser_tool.pybrowser_get_imagesat ~L2705, schema at ~L1397, registry at ~L3488