Skip to content

Add reusable Browser Run sessions#1492

Draft
whoiskatrin wants to merge 1 commit intomainfrom
feat/browser-reusable-sessions
Draft

Add reusable Browser Run sessions#1492
whoiskatrin wants to merge 1 commit intomainfrom
feat/browser-reusable-sessions

Conversation

@whoiskatrin
Copy link
Copy Markdown
Contributor

@whoiskatrin whoiskatrin commented May 9, 2026

Summary

Adds an opt-in reusable Browser Run session mode for the Agents browser tools, while keeping the existing one-shot browser_execute behavior as the default.

This lets callers run multiple browser tool calls against the same underlying Browser Run session so tabs, cookies, local storage, navigation state, and page context can persist across an agent workflow.

A demo of the feature is available here: https://browser-reuse-demo.agents-b8a.workers.dev/

What changed

  • Added reusable browser session lifecycle support in agents/browser:
    • session: { mode: "reuse" }
    • configurable session key / store
    • Browser Run keep_alive support
    • Live View target metadata support
  • Added lifecycle tools when reusable sessions are enabled:
    • browser_session_info
    • browser_close_session
    • browser_reset_session
  • Updated CDP session handling so reusable mode disconnects the WebSocket after each tool call without deleting the Browser Run session.
  • Added Browser Run session helpers for create, reconnect, target listing, and delete operations.
  • Added Think integration that stores the Browser Run session id in the agent Durable Object SQLite database.
  • Added Think browser-session broadcasts so UIs can expose Live View links without requiring the model to put them in chat text.
  • Updated browser docs and Think tool docs for one-shot vs reusable mode, lifecycle expectations, Live View, limits, and cleanup.

Testing

  • npm --workspace agents run test:browser
  • npm --workspace @cloudflare/think run test -- src/tests/browser-tools.test.ts
  • npm --workspace @cloudflare/think run test:e2e -- browser-tools-e2e.test.ts

Notes

  • One-shot browser execution remains the default behavior.
  • Reusable sessions require the Browser Rendering binding; cdpUrl remains externally managed and does not support SDK-owned reusable lifecycle operations.
  • Callers should explicitly close reusable sessions when a browsing task is complete to avoid unnecessary Browser Run usage.

Fixes #1398

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 9, 2026

🦋 Changeset detected

Latest commit: 8491ef4

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

This PR includes changesets to release 2 packages
Name Type
agents Minor
@cloudflare/think Minor

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

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 9, 2026

Open in StackBlitz

agents

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

@cloudflare/ai-chat

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

@cloudflare/codemode

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

hono-agents

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

@cloudflare/shell

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

@cloudflare/think

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

@cloudflare/voice

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

@cloudflare/worker-bundler

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

commit: 8491ef4

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.

browser: allow for tool executions on a single instance

1 participant