Repository navigation
feat(browser)!: size inspect_web_page delivery and page captures by section - #14368
Conversation
…ection inspect_web_page returned the complete capture inline with no detail choice. A local page with 2,000 list rows, 200 buttons and three bundled libraries produced a 4.6 MB MCP result, mostly 6,423 DOM nodes and 10,614 accessibility nodes. inspect_web_page now declares the size-aware detail. Omitted, a capture up to 32 KiB is inline and a larger one is retained behind a summary of its small sections and counts. A new web-page view pages dom (node_names), accessibility (roles), console (types), network (methods), scripts and resources. The shared Evidence handler applies the same size decision as the other size-aware tools and keeps detail out of the capture parameters. BREAKING CHANGE: an MCP inspect_web_page call that omits detail on a capture above 32 KiB now returns the retained summary. Pass detail: "complete" for the previous shape, for example before compare_web_captures. Co-Authored-By: gensokyo-dev <[email protected]>
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
[Medium impact] The reviewed changes appear safe to merge; no new actionable issue remains. SummaryAdds size-aware delivery for
Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[inspect_web_page] --> B[Capture without delivery fields]
B --> C{Delivery choice}
C -->|complete or small capture| D[Complete Evidence]
C -->|summary or eligible large capture| E[Retain complete Evidence]
E --> F[Summary with counts]
F --> G[inspect_analysis_view]
G --> H[Selected section or script text page]
Reviews (4) · Last reviewed commit: "test(browser): request complete captures..." · Reviewed by Greptile |
…ndle The contract's size-aware detail also generated a --detail option for rea inspect-web-page, but the command ignored it and always printed the complete capture. The command now uses the shared CLI Evidence delivery, as analyze-web-bundle does: omitted or complete detail prints the capture, and --detail summary requires --evidence_output and prints the summary with the bundle receipt. Co-Authored-By: gensokyo-dev <[email protected]>
Review found three gaps in the new web-page view: - pages dropped the capture's completeness and the section's context, so an empty accessibility page looked like an exhausted one; - script rows carried their complete captured source, so one large bundle could not be paged; - the summary copied every frame and worker. Every page now carries the capture's completeness and its section's own context beside the page coverage. Script rows keep source metadata without text, and a script-source collection pages one script's text by UTF-16 offset. The summary counts frames and workers, which page through their own collections. Co-Authored-By: gensokyo-dev <[email protected]>
The metadata-budget, URL userinfo, DOM destination and script export verifiers read the complete inspect_web_page capture through MCP. With size-aware delivery, an omitted detail above 32 KiB returns the summary, and the metadata-budget verifier failed reading scripts.items from it. These calls now request detail complete; their CLI calls already return the complete capture. Co-Authored-By: gensokyo-dev <[email protected]>
Unify omitted-detail delivery under the agent result budget. Main's size-aware detail (59a7999, 89919c8, #14368) chose complete or summary with a fixed 32 KiB bound in two handlers; this branch chose it with delivery.agent_result_budget_bytes in tool-result delivery. One decision remains, budgetedSummaryBytes, sized by the setting and applied by ToolResultDelivery and the CLI publication. Main's rule that only a session able to page the summary gets one is kept: the request context records whether the session advertises inspect_analysis_view. SIZE_AWARE_INLINE_EVIDENCE_BYTES, analysisDetailSizeAwareSchema, declaresSizeAwareDetail and deliversRetainedSummary are removed; retainedSummaryDelivery handles only a requested summary, and inspect_web_page keeps detail out of its capture in its own binding. inspect_web_page joins the budgeted operations (45). The default budget is 32,768 bytes: a 73K-character inventory page crossed Claude Code's 25,000-token cap, about 2.9 bytes per token for dense JSON, so 48 KiB would be about 17,000 tokens. The evidence-json default page is derived from it, and the token estimate uses 3 bytes. Main's 32,768/32,769 boundary tests now pin the setting's boundary.
|
Follow-up in #14252: the size decision this PR added for
|
Summary
inspect_web_pagereturned the complete page capture inline, with no delivery choice.On a local page (2,000 list rows, 200 buttons with listeners, 403 console events, rxjs, openpgp and isomorphic-git bundles) under Chromium 156, the MCP result was 4,649,171 bytes:
normalized_resultaccessibility(10,614 nodes)dom(6,423 nodes)console(403 events)Claude Code moves MCP results above about 25,000 tokens out of context.
This PR applies the size-aware delivery from #14328 to
inspect_web_pageand adds aweb-pageview to page the capture.No issue is linked: found during the maintainer's token-optimization survey of the browser domain.
Problem and expected behavior
Before: every call returned the complete capture.
After:
detailomitted, a capture up to 32 KiB of Evidence JSON is inline. A larger one is retained and returns a summary with the small sections (browser, target, capture window, completeness, frames, workers, and the DOM/accessibility/network/console context) and counts.completeandsummaryforce the shape.Verified on the page above:
inspect_web_page(omitted detail)log401,warning1,error1)inspect_analysis_view{kind:"web-page", collection:"dom", node_names:["BUTTON"], limit:3}total201{collection:"accessibility", roles:["button"], limit:3}total201{collection:"console", types:["error","warning"]}{collection:"scripts"}inspect_web_page {detail:"complete"}Change and scope
feat(browser)!: size inspect_web_page delivery and page captures by sectionView:
src/domain/analysisView/webPageView.tsdefines theweb-pagerequest:dom,accessibility,console,network,scriptsandresources;node_names,roles,typesandmethods;offset, andlimitup to 512.It also defines the summary and the projection. Both are registered in the analysis-view request, result and projection tables.
Contract: the
inspect_web_pagerequest extends the existing shape withanalysisDetailSizeAwareSchema, keeping the same refinement. The output accepts the capture or its summary and page views. The description names the view and notes thatcompare_web_capturesneeds the complete capture.Handler:
createEvidenceToolHandler, the shared handler ofrunbindings:detailbefore the operation, so capture parameters and identity are unchanged;deliversRetainedSummarywith the same retention andinspect_analysis_viewpaging conditions as feat(delivery)!: size the default delivery of native inventories and traces #14328.CLI:
feat(cli): deliver inspect-web-page summaries through the Evidence bundleroutes the command through the shared CLI Evidence delivery.Docs:
docs/guides/web/browser-observation.mddescribes the delivery, the view and the comparison caveat. The advertised summary forinspect_web_pageis updated.Not included:
observe_web_execution(1.96 MB on the same page) inlines complete script sources. A separate change will apply the same delivery with a source-text view.compare_web_capturesaccepting retained Evidence references instead of inline captures.Contribution scope: not applicable. This is delivery of read-only Evidence.
Contract and boundary impact
Semantic owner and earliest changed stage: the
web-pageprojection over the existingwebPageInspectionSchema; delivery increateEvidenceToolHandler.Contribution scope fit and linked maintainer decision: the size-aware delivery policy, as in feat(delivery)!: size the default delivery of native inventories and traces #14328.
CLI and MCP/tool-catalog contract:
detailon captures above 32 KiB: they receive the summary. Passdetail: "complete"for the previous shape.rea inspect-web-pageprints the complete capture when--detailis omitted orcomplete.--detail summaryrequires--evidence_outputand prints the summary with the bundle receipt, likeanalyze-web-bundle. Before this PR the generated--detailoption was ignored.Provider, bridge, target-format, or platform compatibility: none. The capture itself is unchanged.
Evidence, artifact, provenance, or reconstruction contract: the complete capture is recorded and reachable through
inspect_analysis_viewordetail: "complete".detailis not part of the capture parameters.Target selection, authority, upstream behavior, and cleanup details: none.
Generated metadata, package, or installation impact: advertised schema summary for
inspect_web_page.Read existing files or captured data.
Evidence and regression coverage
Tests added or updated:
tests/boundary/mcp/webPageViewMcp.test.tsruns through MCP against the fake CDP browser:consolepages filter by type and page by offset;detail: "complete"returns the capture withoutdetailin its parameters;tests/boundary/cli/browserCli.test.ts:--detail summarywithout--evidence_outputfails, and with it prints the summary.Real provider: Chromium 156 on Linux (table above).
Remaining proof gaps:
Observed, derived, and inferred claims remain distinguishable.
Artifact identity, source provenance, and failed attempts remain preserved.
Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.
Validation performed
npm run test:focused --on the browser, CLI, MCP and acceptance tests that useinspect_web_pageoranalyze_web_bundle, plus the analysis-view, contract and server suites: 166 files; 3,420 passed, 3 skipped. The 2 failures were the separateanalyze_web_bundledelivery expectation fixed in its own PR.npm run verify:advertised-schemas(summary updated),npm run docs:checkandnpx tsc --noEmit -p .passed.Compatibility, safety, and release
detail: "complete"to keep complete delivery for large captures.inspect_web_page.Author readiness
Human owner: exempt maintainer account (N0zoM1z0) per CONTRIBUTING.md; readiness boxes left for the human owner.
Before merge
type(scope): outcome.