Skip to content

feat(browser): browser.maxTabs — open refuses past a tab limit (default 6) - #172

Merged
cryptolir merged 2 commits into
mainfrom
feat/browser-max-tabs
Sep 29, 2026
Merged

cryptolir merged 2 commits into
mainfrom
feat/browser-max-tabs

Conversation

@cryptolir

@cryptolir cryptolir commented Sep 29, 2026 •

Copy link
Copy Markdown
Owner

An agent that opens a tab per step piles tabs up until Chrome runs out of memory (social-bob reached 9 tabs and the browser stopped answering on 2026-09-29). The Browser check on the host closes extras a minute later; this makes the pile-up impossible at the source.

  • New config browser.maxTabs (int ≥ 0, default 6, 0 = no limit), in the zod schema, labels, and resolveBrowserConfig (resolveBrowserMaxTabs, also used by the sandbox browser).
  • openTab in server-context.ts counts page targets (not workers/iframes) and throws BrowserTabLimitError; mapTabError maps it to 409 with the message tab limit reached (6 tabs open, browser.maxTabs=6): navigate an existing tab or close one first. Every open path (agent tool, CLI, node proxy) goes through openTab, so one guard covers all of them. If the tab list cannot be read, the open goes ahead.
  • ensureTabAvailable's openTab("about:blank") only runs with zero tabs, so it is never blocked.
  • Folded from the internal review: fetchBrowserJson used to wrap every error, a 409 or a 404 "tab not found" included, as "Can't reach the OpenClaw browser control service … Do NOT retry" — so the model was told the browser was down whenever the service simply said no. Error answers are now thrown as BrowserControlHttpError with the service's own message and status; a real connection failure or timeout still gets the "can't reach, do not retry" wrapper. (This is the likely source of social-bob's "browser service is unreachable, restart the gateway" messages after a tab of his was closed.) And the sandbox browser's hand-built resolved config now carries maxTabs too.
  • Docs: docs/tools/browser.md, docs/gateway/configuration-reference.md.

Tests: server-context.max-tabs.test.ts (refuse at the limit without creating a tab, open under it, page-only counting, default and 0, 409 mapping, config resolution) and client-fetch.http-error.test.ts (a 409 passes through as the service's message; a connection failure still wraps). All of src/browser green. Mutations: guard removed, all targets counted, 409 dropped, sign flipped, rethrow dropped — all caught. tsgo: no errors in src/browser, src/agents/sandbox, src/config (the repo baseline has pre-existing ones in extensions/ and ui/).

Roll-out: pilot on social-bob (DevAgents) with a locally built image; the fleet only moves when the owner promotes a release.

🤖 Generated with Claude Code

Liran Peretz and others added 2 commits September 29, 2026 23:05
…lt 6)

Every open (tool, CLI, node proxy) goes through openTab, so the limit lives
there: with N page tabs already open, open fails with 409 "tab limit reached
(N tabs open, browser.maxTabs=6): navigate an existing tab or close one first".
Workers and iframes do not count; 0 lifts the limit; a failed tab list lets
the open through.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
…they are; sandbox honours maxTabs

Internal review of #172 found two gaps:
- fetchBrowserJson wrapped every error, a 409 "tab limit reached" or a 404
  "tab not found" included, as "Can't reach the browser control service …
  Do NOT retry". The service answered, so the answer is now thrown as
  BrowserControlHttpError with the service's own message and status.
- the sandbox browser built its resolved config by hand, without maxTabs,
  so browser.maxTabs=0 still refused at 6 there. One resolver,
  resolveBrowserMaxTabs, now serves both paths.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@cryptolir
cryptolir merged commit 1273015 into main Sep 29, 2026
19 of 24 checks passed
@cryptolir
cryptolir deleted the feat/browser-max-tabs branch September 29, 2026 23:26
cryptolir added a commit that referenced this pull request Sep 29, 2026
Co-authored-by: Liran Peretz <[email protected]>
Co-authored-by: Claude Fable 5.1 <[email protected]>
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