Repository navigation
feat(browser): cut the Browser instruction section to routing rules - #2288
Merged
Merged
Conversation
The runtime Browser section now says which browser to use, how to confirm it is unavailable, and when to switch after failures. The Browser tool descriptions own the operating rules. browser_open and browser_inspect now carry "finalize before replying", because a flow may never load browser_tabs. They also allow a switch after two failures on the same step instead of forbidding other browsers outright. Closes #2220
The open, inspect and evaluate descriptions still said to use only Mcode's Browser, which contradicted the section's switch after two failures. The section now also says a user hold, Stop or do_not_retry is not a failure to retry around.
…ude factory tests
# Conflicts: # apps/server/src/features/mcode-mcp/toolkits/browser-tool-schemas.ts
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.
What
Before this change, the runtime Browser section was 302 words. It repeated every operating rule from the Browser tool descriptions and included a call-shape example (
s3e12). It also said "use only" Mcode's Browser, so an agent had no sanctioned way out after repeated failures.The section is now 141 words of routing rules only. Operating rules stay in the tool descriptions, which the model loads after it has picked a tool.
The tool descriptions now agree with the section:
browser_openstates the same switch rule. It no longer says to use only Mcode's Browser.browser_openandbrowser_inspectboth say to callbrowser_tabs finalizebefore replying, because a flow may never loadbrowser_tabs.Verification
Tests:
thread-orchestration: 21 passed. A new test checks that the section is under 200 words, contains no call shapes, and states the prefer and switch rules.providers: the full package suite passed (112 files, 1,707 tests). The adapter tests now expect the new "Prefer" wording. The Claude factory tests detect the Browser section bybrowser_inspect, because the section no longer namesbrowser_tabs.server: 35 passed (browser-toolkit,mcp-conformance,mcode-instruction-boundaries). A new test checks the finalize rule onbrowser_openandbrowser_inspect.Live runs in the Electron app against a local fixture page (an order form with a Name input and a Save button). Each agent had only the new section and the tool descriptions:
browser_openfailed with "Browser became unavailable". It retried in Mcode's Browser, then inspected, typed, clicked, inspected again, finalized, and answered "Saved order for Ada". It ran no shell commands and opened no other browser.s1e1before inspecting. The server refused withSTALE_TARGET_GENERATION. Claude inspected, completed the form in Mcode's Browser, quoted the error, and answered "Saved order for Ada".Why
Agents choose a browser before any Browser tool description loads. The section must win that choice, and it should not repeat rules the model will read in the tool descriptions anyway. A shorter section also leaves more room in each provider's context. The explicit switch rule gives agents a bounded exit after two failures on the same step, so they neither give up after one failure nor loop on a broken Browser.
Closes #2220
Review Notes
docs/internals/providers/mcode-agent-instructions.mdnow explains the split between routing rules and operating rules.browser_openrepeats the switch rule, so both places need editing when the rule changes.browser_inspecttaking atabIdfrom feat(browser): let the agent read the user's own Browser tab #2287. Merging main kept feat(browser): let the agent read the user's own Browser tab #2287's tab-reading sentences in thebrowser_inspectdescription and dropped its "Use only mcode MCP browser tools" clause, which contradicts the switch rule.