fix(agent): tell the model that navigating a page is not reading it#5765
Open
MummIndia wants to merge 1 commit into
Open
fix(agent): tell the model that navigating a page is not reading it#5765MummIndia wants to merge 1 commit into
MummIndia wants to merge 1 commit into
Conversation
browser_navigate returns the page title and a snapshot reference. It never returns the page text. Asked to open a URL and summarise it, the agent called browser_navigate, saw exit_code=0, answered "the page loaded successfully" and stopped -- having read nothing. It looks like a successful turn, and the tool log agrees, so nothing flags it. browser_snapshot has the same trap one level down. Its optional filename argument is documented as "Save snapshot to markdown file instead of returning it in the response". The model volunteered a filename and so received a path it had no way to open: 175 characters of reference where omitting the argument returns 1634 of content. Adds a note covering both. Navigate is never the last step, follow it with browser_snapshot or browser_find; call snapshot with no arguments; and prefer web_fetch when the task is only to read a page, since it does the whole thing in one call rather than three round trips -- which matters on local hardware where each round trip is a full generation. Injected only when browser tools are in that turn's selection, and suppressed with the other local-context blocks, so it costs nothing on unrelated requests. Verified present with browser tools in the set and absent without. Observed after the change: the agent that previously stopped at "the page loaded" went on to call browser_snapshot on its own. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
browser_navigatereturns the page title and a snapshot reference. It never returnsthe page text. Asked to open a URL and summarise it, the agent called
browser_navigate, sawexit_code=0, answered "the page loaded successfully" andstopped — having read nothing. The turn looks successful and the tool log agrees, so
nothing flags it.
browser_snapshothas the same trap one level down: its optionalfilenameargumentis documented as "Save snapshot to markdown file instead of returning it in the
response", and the model volunteers one. It then receives a path it cannot open —
175 characters of reference where omitting the argument returns 1634 of content.
This adds a note covering both. Navigation is never the last step, follow it with
browser_snapshotorbrowser_find; call snapshot with no arguments; and preferweb_fetchwhen the task is only to read a page, since it does the whole thing inone call rather than three round trips — which matters on local hardware where each
round trip is a full generation.
The note is injected only when browser tools are in that turn's selection, and is
suppressed alongside the other local-context blocks, so it costs nothing on unrelated
requests.
Target branch
dev, notmain.Linked Issue
Fixes #5764
Type of Change
Checklist
devdocker compose up) and verified the change works end-to-end.How to Test
Run with the built-in browser MCP server connected, in agent mode.
Send:
Open https://example.com and summarise what this page is about.Before the change — the agent calls
browser_navigate, then ends the turn witha message along the lines of "the page loaded successfully", without answering the
question. The round summary reads
0 native calls, 0 tool blocks.After the change — the agent follows
browser_navigatewithbrowser_snapshotand answers from the page content. Confirmed in the logs:
To check the conditional injection, build the system prompt with and without a
browser tool in
relevant_tools. TheREADING A WEB PAGEblock is present in thefirst case and absent in the second.
Visual / UI changes
None. This PR only touches
src/agent_loop.py— prompt text assembled server-side.No HTML, CSS, SVG or
static/js/module is modified.