Skip to content

feat(agents): add TanStack AI browserTool for a persistent browser - #2428

Merged
ben-reitz merged 2 commits into
mainfrom
feat/tanstack-browser-tool
Oct 1, 2026
Merged

ben-reitz merged 2 commits into
mainfrom
feat/tanstack-browser-tool

Conversation

@ben-reitz

@ben-reitz ben-reitz commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

TL;DR: Adds browserTool to agents/browser/tanstack-ai, the TanStack AI version of the persistent browser tool from agents/browser/ai-sdk.

import { browserTool } from "agents/browser/tanstack-ai";

chat({
  adapter,
  tools: [browserTool({ browser: this.browser, loader: this.env.LOADER })],
  messages
});

What changed

  • Shared core. The setup code behind browserTool (connector, codemode runtime, browser report) moved into an internal browser/browser-tool.ts. Both ai-sdk.ts and tanstack-ai.ts build on it, so they behave the same: active tab, newTabs, restarted / notice, runtime name.
  • TanStack adapter. Takes the same options as the AI SDK tool, plus an optional name (default "browser"). Returns a ServerTool, and the name's type follows name.
  • Output. TanStack AI gives the host and the model the same output, so the tool returns what the model should see: no calls log and capped logs. Screenshots aren't supported yet: a returned screenshot is replaced by a note saying it was left out (restart notices and newTabs still come through), and the tool's cdp hint tells the model to read the page with Runtime.evaluate instead. Each adapter now supplies its own screenshot hint to the shared core, so the AI SDK tool keeps its "the UI keeps the image" wording.
  • codemode. The codemode tool's input schema now declares ~standard.types (type-only), so TanStack AI types the input as { code: string } without a cast.
  • The old TanStack createBrowserTools is still there and not deprecated.

Tests

  • browser-capability.test.ts: tool name, reuse of the same persistent browser plus restart reporting, the screenshot note and hint, and the restart notice kept alongside the screenshot note.
  • browser-tool.test-d.ts: it's a ServerTool, and the name type follows name.

Docs and changesets

  • Short TanStack paragraph in the "Persistent browser" section of docs/agents/browse-the-web.md, plus packages/agents/AGENTS.md.
  • agents patch and @cloudflare/codemode patch.

@changeset-bot

changeset-bot Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: ad902a4

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@cloudflare/codemode Patch
agents Patch
@cloudflare/agent-think Patch

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

@agent-think

agent-think Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

🟡 agents import sizes: 1 entry point grew

Entry point Exports Largest gzip change Size now
🟡 agents/browser/tanstack-ai 1 resized, 1 new +1 KiB (+0.61%) 164.2 KiB
Changed exports (2)
Import Gzip change Size now
🟡 agents/browser/tanstack-ai#createBrowserTools +1 KiB (+0.61%) 164.2 KiB
🆕 agents/browser/tanstack-ai#browserTool — 156.6 KiB
How this works

Each runtime export is bundled on its own, minified, and gzipped. Changes smaller than 100 B, or smaller than 1% and 1 KiB, are ignored. Growth over 10% or 5 KiB is marked 🔴. This report is informational and does not fail CI. The workflow artifact contains every measurement.

Compared 0c297171 → ad902a41 · workflow run · reported by agent-think[bot]

@ben-reitz
ben-reitz marked this pull request as ready for review October 1, 2026 13:18
devin-ai-integration[bot]

This comment was marked as resolved.

@pkg-pr-new

pkg-pr-new Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

agents

npm i https://pkg.pr.new/agents@2428

@cloudflare/ai-chat

npm i https://pkg.pr.new/@cloudflare/ai-chat@2428

@cloudflare/codemode

npm i https://pkg.pr.new/@cloudflare/codemode@2428

hono-agents

npm i https://pkg.pr.new/hono-agents@2428

@cloudflare/shell

npm i https://pkg.pr.new/@cloudflare/shell@2428

@cloudflare/think

npm i https://pkg.pr.new/@cloudflare/think@2428

@cloudflare/voice

npm i https://pkg.pr.new/@cloudflare/voice@2428

@cloudflare/worker-bundler

npm i https://pkg.pr.new/@cloudflare/worker-bundler@2428

commit: ad902a4

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 new potential issue.

Devin Review

});
```

The TanStack AI tool doesn't support screenshots yet. TanStack AI gives the host and the model the same output, so if the model returns a screenshot, the tool replaces it with a note saying it was left out, and the tool's instructions tell the model to read the page with `Runtime.evaluate` instead.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 Documentation uses a contraction

The screenshot explanation says “doesn't,” while the documentation style guide requires “does not.”

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

@ben-reitz
ben-reitz merged commit e780214 into main Oct 1, 2026
18 checks passed
@ben-reitz
ben-reitz deleted the feat/tanstack-browser-tool branch October 1, 2026 14:37
@github-actions github-actions Bot mentioned this pull request Oct 2, 2026
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