Repository navigation
Description
Problem
Using get_app_state to drive Chrome for sustained web research costs a lot of context, even with include_screenshot: false and interactive_only: true:
- A typical results page fills the 32 KB inline budget on every look (~31 KB / ~9k tokens per call), whatever the agent actually needs from it.
- The text a research agent wants (prices, descriptions, listing titles) usually sits past the inline prefix, so the agent either pages through the cached tree with
get_tree_page(hundreds of KB on a large page) or needs shell access to search the spill file. interactive_only: truefilters the tree before it is cached and spilled, so the page text it drops cannot be retrieved from that snapshot at all. A second, unfilteredget_app_statereplaces the snapshot, so the indices the agent was about to click become invalid.- Compact nodes still carry
object_ref,depth,parent_index,bounds,actions,child_countand routine states (enabled,visible,showing, ...), which navigation rarely needs.
Measured on eBay with v0.7.60 (Debian 13, GNOME 48 on X11, Chrome with --force-renderer-accessibility): a search-and-listing sequence (find the search box, search, read listing titles and prices, open the first listing, read its title and price) moved ~404 KB of tool results in 20 calls, 10 of them get_tree_page paging calls. That was with the agent keeping one snapshot per page so its indices stayed valid.
Proposal
Opt-in additions that keep the whole tree in the local snapshot and let the agent retrieve only what it needs. Existing behaviour, including action resolution on interactive_only snapshots, is unchanged.
tree_detail: "minimal" | "compact" | "full"onget_app_state,get_tree_pageand post-actioninclude_tree. Minimal nodes are{index, role, name, text (when it differs from the name, U+FFFC removed), value, states (non-routine only)}. The existingNodeDetailplumbing (inline result, spill file, paging,TreeShape) already carries an encoding choice, so this is a new variant and its encoder.max_tree_bytesonget_app_stateand post-actioninclude_tree: caps the inline tree (default and ceiling stay 32000).0returns no nodes, but the call still reads the desktop, caches the whole tree under a newsnapshot_idand writes the spill file. Errors, warnings, truncation and the readiness block are unaffected.- Search in
get_tree_page:query(case-insensitive text in name, text or description),role, andwithin(anelement_indexsubtree). It filters the cached snapshot without re-reading the desktop, keeps snapshot_id checks, and pages the matches as today.withinis applied on the whole tree, so a plain container (a results list) still bounds a search of the interactive view. interactive_onlykeeps the whole tree for searching only. The snapshot keeps the interactive view exactly as today, and every action (element_index, selectors, bounds, recovery) resolves against it unchanged. The whole compacted tree is stored beside it and read only byget_tree_pagewhen a filter orinteractive_only: falseis passed. One snapshot can then serve navigation and research, without a secondget_app_statereplacing the indices the agent is about to click. Existing callers see no difference.
The same eBay sequence with these options: ~41 KB in 15 calls, about 10x less tool-response text than the MCP-only baseline. (An agent with shell access could search the spill file instead of paging. These options give a similar saving through MCP alone.) A research step becomes get_app_state {interactive_only, tree_detail: "minimal", max_tree_bytes: 0} (~1.7 KB), then get_tree_page {query: "£", interactive_only: false, tree_detail: "minimal"}.
I have an implementation with tests and can open a PR if this direction works for you.
Related observations (not part of the proposal)
CallToolResult::structured(rmcp 3.9) sends each result both as a text block and asstructuredContent. Claude Code passed one copy to the model in my tests, so this did not affect token use there, but other hosts may count both.get_app_statefor an app name that matches nothing reports only "Captured 0 accessibility nodes", with no explicit "no app matched" error.
Activity