Repository navigation
fix(agents): give browserTool its own description instead of codemode's - #2488
Merged
Merged
Conversation
🦋 Changeset detectedLatest commit: 7460e9f The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
|
✅ agents import sizes: no significant changes ( |
agents
@cloudflare/ai-chat
@cloudflare/codemode
hono-agents
@cloudflare/shell
@cloudflare/think
@cloudflare/voice
@cloudflare/worker-bundler
commit: |
ben-reitz
marked this pull request as ready for review
October 6, 2026 10:33
Merged
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
browserToolnow passes its own description to codemode instead of using codemode's generic one. That text told the model tocodemode.searchfirst (search doesn't cover CDP commands) and described approvals, snippets, and replay, which this tool doesn't use. This change applies to the AI SDK, TanStack AI, and pi tools, because all three use the same core.createBrowserToolCore (browser/browser-tool.ts) runtime.tool({ - connectorHints: { cdp: BROWSER_INSTRUCTIONS } # appended to codemode's generic text + description: intro + cdp API + BROWSER_INSTRUCTIONS + timeout + screenshotHint })It also corrects the
timeoutMsdoc comment, which said the default was 30s; the real default is 60s.Evidence
codemode.search("cdp navigate page evaluate links")andcodemode.search("scrape links")both returned[], then it calleddescribeoncdp.sendandcdp.spec. It then used fixed sleeps instead ofreadyState, readexceptionDetailsfrom the wrong place, and wrote a 120-page crawl inside a 60s run.After: the description includes the rules for each of those mistakes and has no search step. Not yet re-run with a real model.
After: I checked them against real Chrome with a probe:
Runtime.evaluatecompletes, withexceptionDetailsat the top level.returnByValue, an object comes back with only anobjectId.awaitPromise, a promise comes back as{}.Page.navigateto an unresolvable host returnserrorTextand doesn't throw.readyStateis stillloadingright afterPage.navigate.cdp.spec()is 656 KB.fetchis blocked, andsetTimeoutworks.Promise.allovercdp.sendworks.After: the test
explains how to take a smaller screenshot when one is too largepasses. The error suggests capturing the viewport only or using JPEG.describes cdp and its rules without codemode's generic textpasses. It checks that the description containssessionId: "active",returnByValue: true,document.readyState, andtimes out after 60s, and doesn't containcodemode.search,paused, orSnippets.pnpm run check, the browser capability and connector tests, and 24 real-Chrome tests pass.Merge Danger
Door: two-way
Only the tool's description text and one error message change. There's no new API and no stored data.
Blast Radius: model-behaviour
The tools in
agents/browser/ai-sdkandagents/browser/tanstack-ai, and the upcomingagents/browser/pitool, all get the new description. The model no longer hears aboutcodemode.search,codemode.step, or snippets. None of those do anything useful for this tool today. A screenshot over 1 MB fails with a different message; it already failed before.createBrowserToolsis unchanged.