Skip to content

Browser first-use documentation fits inline in Claude Code (#494) - #508

Merged
SSFSKIM merged 9 commits into
mainfrom
fix/494-inline-first-use
Nov 23, 2026
Merged

SSFSKIM merged 9 commits into
mainfrom
fix/494-inline-first-use

Conversation

@SSFSKIM

@SSFSKIM SSFSKIM commented Nov 23, 2026 •

Copy link
Copy Markdown
Owner

Closes #494. Version 0.29.5 (main merged in at a08fa84). Design rulings 1107, 1133.

The gap

The first getBrowser() result was about 55 KB in a MAWS session, so Claude Code saved it to a file instead of showing it. One agent had to grep that file to find the Tab interface. Another never read it and guessed browser ids.

The measured limit

  • Claude Code 2.1.330 shows an MCP result inline up to 50,000 characters, counted across its text items. Above that it saves the result to a file with a 2 KB preview.
  • MAX_MCP_OUTPUT_TOKENS is a separate 25,000-token step and doesn't move this limit.
  • Confirmed with three claude -p runs (haiku, low effort, 12 tool calls in all) against a throwaway stdio MCP server, in a scratch HOME: 50,000 chars was inline and 50,001 was saved, the same split for two items, and the same with the token setting raised.
  • Target: the first cell at ≤ 47,500 characters.

The fix (cua's own host and the shared browser part; the vendor host's core document is untouched)

  • Inline: the header with the Name line, session naming, the requiredFor documents (unchanged), Browser, Tabs and Tab in full, and a slim PlaywrightAPI/Locator part drawn from the manifest's own declarations.
  • Lookups: the guidance moved to lookups (browser-safety, tab-cleanup-chrome, browser-control-interruption, cua-browser-service, api-use-behavior). Each has a one-line pointer stating its rule and is read with nodeRepl.write(await agent.documentation.get(...)). A bare await returns the text without showing it.
  • Full reference: api-reference/<browser id>, one per documented browser.
  • Own REPL host 0.5.2: the API its first call documents changed.

Evidence

First cell, in characters (Chrome profile; MAWS differs by ~20):

Surfaces main this PR margin under 50,000
browser only (MAWS) 55,436 28,707 43%
Linux computer + browser 61,369 34,649 31%
macOS computer + browser (plugin default) 73,395 46,675 7%

interface Tab { now starts about 5,200 chars into the browser document (it was ~17,200). goto is at ~6,600.

Tests:

  • test/cua-api/first-use-inline.test.mjs checks:

    • the target on MAWS and Chrome-profile selections under all three cores;
    • Tab/goto/markHandoff within the first 7,000 chars;
    • that every pointer resolves;
    • that every advertised lookup prints when run in a real kernel under cua's host;
    • A→B→A per-browser references.

    It fails on main.

  • The focused set passes 165/165 (with CUA_NODE on Node 26). browser-service, cua-api and repl-parity pass 1,254/0.

Review (reviewer-medium): 2bed9d8 had 1 P1 (the lookup didn't print), 2 P2 and 1 P3, all fixed in d59091a except the one below. The re-review found nothing.

Limits

Parity

The full-reference pointer names its browser (api-reference/<browser id>), and browser ids are numbered per service process, so they drift between the vendor and cua hosts. The parity oracle (scripts/repl-parity/docs-oracle.mjs, browser-identity.mjs) now normalises exactly that one slot, bound to the header's own id; a pointer to another id, or the id anywhere else, still differs (f052a51, with oracle tests). No declarations were added. Hosted parity-browser passes on 1670f7c (run 45173262693).

Sminos-Session: cursor235#b93055dd (cua on macbook)

…owser, Tabs, Tab and a slim Playwright/locator reference; guidance by name (refs #494)

Claude Code saves an MCP result of more than 50,000 characters to a file, and the first getBrowser() cell (core
plus browser document) was 55.4K with the browser surface alone and 73.4K with a macOS computer surface. The
first-use document keeps the selected browser, session naming and the requiredFor documents, the lookup catalogue
and capabilities, and an API reference of Browser, Tabs and Tab whole with the common Playwright and locator members
(SUMMARY, the manifest's own declarations). The safety, tab cleanup, interruption, API use and cua-browser-service
guidance become lookups whose pointer states the rule; "api-reference" is the full reference, generated for the
browser last documented. The browser document drops from 36.5K to 9.5K; first-use-inline.test.mjs holds the first
cell at 47,500 or less on MAWS and a Chrome profile under every core, with the Tab interface in its first 7,000
characters. Own host 0.5.2.

Sminos-Session: cursor235#b93055dd (cua on macbook)
…use split (refs #494)

Sminos-Session: cursor235#b93055dd (cua on macbook)
…494)

Sminos-Session: cursor235#b93055dd (cua on macbook)
…o its browser, and retries follow inspection (refs #494)

Review of 435420c..2bed9d8. A lookup returns its text without showing it on the own host, so the catalogue's
clause, the api-reference pointer, the capability lines, the manifest's documentation() comments and the
required-documentation error all advertise nodeRepl.write(await ...); the parity oracle names the catalogue clause as
cua's edit of the vendor's. A test runs each advertised example as written in a real kernel under cua's REPL host and
checks the looked-up text in the visible tool response (and that the bare form shows nothing). The full reference is
api-reference/<browser id>, one per documented browser, so after A, B, A each pointer reads its own backend's
reference (covered with backends that differ on selectOption). The API use pointer says never blindly repeat, and to
inspect and resolve before retrying, as its guide does.

Sminos-Session: cursor235#b93055dd (cua on macbook)
…rence (refs #494)

Sminos-Session: cursor235#b93055dd (cua on macbook)
Sminos-Session: cursor235#b93055dd (cua on macbook)
…494)

Sminos-Session: cursor235#b93055dd (cua on macbook)
… one bound slot (refs #494)

Since #494 the first-use document names its full reference as api-reference/<browser id> in the catalogue and the
summary's pointer, and browser ids are numbered per service process, so the two hosts' documents differed in that
name alone (hosted parity-browser, run 45158364542: 13 docs-profiles cells and api/cua/rewritedocumentation).
normalizeSelectedBrowserDocument and applyBrowserIdentity now project exactly that name, delimited by its quote or
backtick, with the header's ID; a pointer to another ID, a longer ID that starts with it, and the ID anywhere else
still compare.

Sminos-Session: cursor235#b93055dd (cua on macbook)
Sminos-Session: cursor235#b93055dd (cua on macbook)
@SSFSKIM
SSFSKIM marked this pull request as ready for review November 23, 2026 13:00
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-23T13:06:36.176703Z 1670f7c Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@SSFSKIM
SSFSKIM merged commit c02bbae into main Nov 23, 2026
7 checks passed
@SSFSKIM
SSFSKIM deleted the fix/494-inline-first-use branch November 23, 2026 13:00
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 first-use doc is ~56 KB, so Claude Code saves it to a file; put the selected browser and the Tab API inline

1 participant