Skip to content

feat(browser): name the page's console errors in the agent's next page answer - #956

Merged
omartelo merged 2 commits into
mainfrom
feat/browser-console-errors
Oct 28, 2026
Merged

omartelo merged 2 commits into
mainfrom
feat/browser-console-errors

Conversation

@omartelo

@omartelo omartelo commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

What

The page answer an agent gets from its session's browser (browser_info, browser_click, browser_press) now names the console errors the page showed since the agent's last page answer, once each:

url: http://127.0.0.1:5173/
title: Console
console error: load failed: 42
console error: Failed to load resource: the server responded with a status of 404 (Not Found) http://127.0.0.1:5173/missing.png
console error: Uncaught TypeError: Cannot read properties of null (reading 'f') (http://127.0.0.1:5173/:3)
text: throw
...

An agent that changed a web app and drives it had only a screenshot to hint that the page threw; now the exception or the failed load is in the answer.

How

  • internal/browser/console.go: the page hands each console error to a per-session sink, kept until the next page answer, the same pattern as downloads. Sources, all already enabled by chromedp: Runtime.consoleAPICalled of type error, Runtime.exceptionThrown (first line of the error plus url:line), and Log.entryAdded at level error (a resource that failed to load, CSP). Warnings, info and log messages are not collected.
  • Caps are named constants: the first consoleErrorMax (5) errors are kept, the rest only counted and reported as (N more console errors); each text is folded to one line and cut to consoleTextMax (200) runes. A page that throws in a loop costs a bounded number of tokens.
  • Page.Listen takes one more callback; api.BrowserPageInfo gains consoleErrors and consoleErrorsMore (contract.golden updated).
  • The browser_info/click/press tool descriptions say so in one clause; docs/browser-tab.md has a Console errors section; CHANGELOG entry under Added.

Privacy

The text is exactly what the page logs (its own console.error arguments, an exception's message, the URL of a resource that failed). lich reads nothing else from the page for it; a page that logs a form's value hands it to the agent, as it would to anyone with DevTools open.

Language

Like the rest of the page answer, the console error: lines are English outside the prompt-language catalogs. Moving the page answer into the catalogs is a separate follow-up.

Test plan

  • Unit tests with the fake page: reported once by read, click and press; cap and count; one-line cut; text of a console call, an exception and a log entry.
  • Live test (console_live_test.go, same skip rule as the other Chrome tests): a page that logs an error and a warning and asks for a missing image; the first reads name the error and the 404, not the warning; a click on a button that throws answers with the one Uncaught TypeError; the next read repeats nothing. 30/30 runs green.
  • The two existing Listen calls in chrome_live_test.go get the new argument (the signature changed), nothing else.
  • gofmt, go vet ./... and go test ./... green, rebased on feat(browser): browser_info waits for text to appear or go #955 and fix(browser): stage Chrome's downloads in the session profile #960.

@omartelo
omartelo force-pushed the feat/browser-console-errors branch from 250a0a5 to 4641f17 Compare October 28, 2026 13:14
@omartelo
omartelo merged commit 8f9a23f into main Oct 28, 2026
7 checks passed
@omartelo
omartelo deleted the feat/browser-console-errors branch October 28, 2026 13:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant