Skip to content

Move surface rules from the host notes into tool descriptions (#73) - #75

Merged
SSFSKIM merged 2 commits into
mainfrom
feat/notes-into-descriptions
Oct 7, 2026
Merged

SSFSKIM merged 2 commits into
mainfrom
feat/notes-into-descriptions

Conversation

@SSFSKIM

@SSFSKIM SSFSKIM commented Oct 7, 2026 •

Copy link
Copy Markdown
Owner

Closes #73

The server instructions had 3 of Claude Code's 2,048 characters left (Linux computer,browser, 2,045). Following the owner's decision, they now keep only the rules for every call on every surface, and each surface's own rules move into the description of the tool they govern.

Where every rule went

Old host-notes line (main) New home
Host notes: title; "Use when a macOS/Linux app's GUI is the only way…" / "Use for the user's existing Chrome profiles…" heads instructions (unchanged)
Call end_task as soon as the task is done… An error spends the connection instructions
One controller per task, one js call at a time. Only timeout_ms stops a running cell instructions
Observe, act, verify… stop and find out why rather than repeat instructions
Batch deterministic steps. Wait for a visible readiness condition in a bounded poll instructions
Never read the secret store; type secrets as {{secret:KEY}} instructions
Apps ask for approval once per connection (macOS) instructions (macOS with the computer surface)
devices_use moves every tool to that machine… end_task first instructions (reworded: "under the notes and descriptions it returns") + devices_use description
Prefer accessibility element indexes; coordinates are screenshot pixels (downscale); role names in the system language js description, macOS
Drop a quit app's handle: getAXState() relaunches it js, macOS
typeText drops characters the layout cannot key (emoji) js, macOS
If REPL state is confused, js_reset and rebind; never also use osascript js, macOS
Linux: bind by window, cua.getApp({windowId}) / listWindows, js_reset and rebind js, Linux
Linux: typeText and paste crash GTK3 text views; pressKey, one X keysym per call js, Linux
Linux: element indexes, downscaled coordinates js, Linux
Linux: no app asks for approval; the trusted wrapper is not a boundary js, Linux
getBrowser only with an id profiles_list returned; never pick or bind a profile profiles_list description
Chrome tabs are DOM-only; keys on a focusable element; tab.cua.type pastes profiles_list (+ a pointer line in js)
Locator actions, waits and evaluate stop at 3 s; loop short waits profiles_list (+ pointer)
evaluate is read-only profiles_list (+ pointer)
createBrowserTab 60 s, leftover tab, one-window unload, handoff profiles_list (+ pointer)
new: "Each tool's description carries the rules for its surface" instructions
new (from the Phase F spec): Linux setValue/selectText do not exist; paste types js, Linux

test/mcp-browser-surface.test.mjs pins every rule to its new home with a regex, asserts each is absent from the instructions, that no macOS-only rule reaches anything a Linux model sees, that cua's lines sit before the 2,048-character description cut even behind a 3,000-character vendor text, and that the instructions stay under 1,400 characters on all 12 platform × surface × devices combinations.

Instructions length (vendor's 63-character line included): macOS computer 846 (955 with devices), browser 792 (901), computer+browser 846 (955); Linux computer 765 (874), browser 792 (901), computer+browser 765 (874).

Two things the brief did not anticipate

  1. Tool descriptions are capped too. Claude Code 2.1.292 truncates each MCP tool description to 2,048 characters (CLAUDE_CODE_MAX_MCP_DESCRIPTION_LENGTH, keeps the head, appends "… [truncated]"). So cua's lines come first. profiles_list is 1,102 and devices_use 507. With the computer surface alone, js is 415 + 2 + the vendor's 1,511 = 1,928, so it fits whole. With the browser surface the vendor's own js text was already over the cap before this change (2,847 browser-only, 2,952 with both). cua's lines push out more of that tail: the in-app, MCP Apps and named-browser options, which cua's Chrome route doesn't use. The first js call still returns the whole API document. Logged in tech-debt-tracker.md: with both surfaces (the plugin's default), the cut already hid cua.getApp(...) before this change.
  2. Remote devices. A device's surface rules now live in its own tool descriptions, which the local stdio client never lists. So devices_use sends tools/list to the device while switching and returns its js and profiles_list descriptions as tools beside hostNotes, in the structured content and in the text's JSON line. A device that can't list its tools isn't switched to (device_protocol); the target stays unchanged and the new session is ended. Without this, a macOS client switching to a Linux device would lose the Linux rules.

Also: the acceptance runner's C4 check now reads the Chrome rules from profiles_list's description. README "Operating guidance for agents" (and the lines that said "the host notes say so") now say where the rules live. Decision Log entry dated 2026-10-07. Plugin 0.3.2.

Verification

  • npm test: 781 tests, 780 pass, 1 platform skip, 0 fail.
  • Independent review (opus, reviewer-high brief): verdict correct, every rule from main found at its new home and none on the wrong platform. One P3 fixed in the second commit: a devices_use cancelled while the device's tools/list was in flight could still switch if the device answered anyway; it now ends the new session and is withdrawn, with a test that fails without the fix. Not changed: the Linux vendor js description length is unmeasured here (no Linux runtime on this Mac), so whether the Linux computer-only js description fits whole (cua's 576 characters plus the vendor's) is unverified; cua's own lines are inside the cut either way.
  • Live check: the worktree's cua-shim.mjs registered as cua_repl (CUA_SHIM_SURFACES=computer,browser), claude -p "list the Chrome profiles, then tell me verbatim the rules you were given about driving Chrome tabs" --tools "" --strict-mcp-config --mcp-config <file> --allowedTools mcp__cua_repl__profiles_list (Claude Code 2.1.292). The model called profiles_list, then end_task, and quoted the description's rules back, DOM-only and 3 s included. It attributes the js pointer line to "the server instructions", but the line is in the js description. Instance ids elided:
Chrome profiles registered for browser use:

- **personal** — ready (`extensionInstanceId`: `<instance id>`)
- **school** — ready (`extensionInstanceId`: `<instance id>`)
- **work** — not ready: `extension_not_installed`

The server's own note on `work`: "work is not ready (extension_not_installed): the OpenAI extension is not installed in this Chrome profile (install it there yourself; cua never does). Tell the user; do not bind or pick a profile for them."

I have not bound either ready profile to anything — that choice is yours.

**Verbatim, the rules attached to the `profiles_list` tool:**

> List the Chrome profiles the user registered for browser use, by key, with whether each is ready and, when ready, its extensionInstanceId; a profile that is not ready says why, and no other profile stands in for it. Call it before any Chrome work, and drive Chrome by these rules:
> - Give cua.getBrowser({extensionInstanceId}) only an id profiles_list returned for the profile the user means; if that fails, call profiles_list again. Never pick or bind a profile for the user.
> - Chrome tabs are DOM-only: tab.playwright locators, not native input; press keys on a focusable element, never a frame body; tab.cua.type pastes.
> - Locator actions, waits and evaluate stop at 3 s (timeoutMs can only shorten it); to wait longer, loop short waits to your own deadline under a larger js timeout_ms.
> - evaluate is read-only: no fetch, no require, objects are non-extensible.
> - createBrowserTab can take 60 s (js timeout_ms of at least 60000); after a timeout a tab may still have opened: tell the user, don't retry. In a one-window profile, closing your tab or end_task unloads it; mark a tab handoff to keep it.

**And the related line from the cua_repl server instructions:**

> Chrome: follow the rules in profiles_list's description (DOM-only tabs, the 3 s cap, read-only evaluate, slow createBrowserTab).

That is the complete set of Chrome-tab rules I was given. Nothing was opened or changed on any profile.

The server instructions had 3 of Claude Code's 2,048 characters left.
They now keep only the rules for every call on every surface (when to
use cua, end_task, one controller, observe-act-verify, batching and
bounded polls, cancellation, macOS's per-app approval, the secret
store, the devices rule) and measure 765 to 955 characters with the
vendor's line. Each surface's own rules are in the description of the
tool they govern: the Chrome rules in profiles_list's, the macOS or
Linux computer rules ahead of the vendor's js description (whose schema
and text pass through), the device rule in devices_use's.

A device's surface rules are now in its own tool descriptions, which
the local client never lists, so devices_use lists the device's tools
while switching and returns its js and profiles_list descriptions as
`tools` beside `hostNotes`; a device that cannot list them is not
switched to (device_protocol).

Claude Code 2.1.292 caps tool descriptions at 2,048 characters too,
keeping the head, so cua's lines come first and every description cua
writes fits. The acceptance runner's C4 check reads the Chrome rules
from profiles_list's description. Plugin 0.3.2.
…ools

The device can answer a tools/list whose devices_use the client has
already cancelled. The switch then went ahead and its answer went to a
withdrawn request, so the model believed it was still on local. A
cancelled switch now ends the new session and is withdrawn (review of
#73). Also two places that still said the host notes carry the Chrome
rules.
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.

Host notes budget is spent (2,045/2,048): move rules into tool descriptions or the first-call document

1 participant