Skip to content

feat(browser)!: size inspect_web_page delivery and page captures by section - #14368

Merged
morluto merged 4 commits into
mainfrom
feat/web-page-view
Nov 24, 2026
Merged

morluto merged 4 commits into
mainfrom
feat/web-page-view

Conversation

@N0zoM1z0

@N0zoM1z0 N0zoM1z0 commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

inspect_web_page returned 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:

Section of normalized_result JSON bytes
accessibility (10,614 nodes) 1,476,425
dom (6,423 nodes) 815,497
console (403 events) 97,547
everything else under 7 KB

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_page and adds a web-page view 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:

    • With detail omitted, 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.
    • The counts are: DOM and accessibility nodes, console events in total and by type, network requests, WebSocket connections, scripts, resources, metadata responses, DOM URLs, agent hints, storage keys and fingerprints.
    • Explicit complete and summary force the shape.
  • Verified on the page above:

    Call Bytes Result
    inspect_web_page (omitted detail) 12,545 summary; counts 6,423 DOM / 10,614 accessibility / 403 console (log 401, warning 1, error 1)
    inspect_analysis_view {kind:"web-page", collection:"dom", node_names:["BUTTON"], limit:3} 8,245 total 201
    {collection:"accessibility", roles:["button"], limit:3} 8,703 total 201
    {collection:"console", types:["error","warning"]} 8,453 2 rows
    {collection:"scripts"} 12,407 4 scripts
    inspect_web_page {detail:"complete"} 4,649,171 complete

Change and scope

  • feat(browser)!: size inspect_web_page delivery and page captures by section
    • View: src/domain/analysisView/webPageView.ts defines the web-page request:

      • collections dom, accessibility, console, network, scripts and resources;
      • exact filters node_names, roles, types and methods;
      • offset, and limit up 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_page request extends the existing shape with analysisDetailSizeAwareSchema, keeping the same refinement. The output accepts the capture or its summary and page views. The description names the view and notes that compare_web_captures needs the complete capture.

    • Handler: createEvidenceToolHandler, the shared handler of run bindings:

    • CLI: feat(cli): deliver inspect-web-page summaries through the Evidence bundle routes the command through the shared CLI Evidence delivery.

    • Docs: docs/guides/web/browser-observation.md describes the delivery, the view and the comparison caveat. The advertised summary for inspect_web_page is 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_captures accepting 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-page projection over the existing webPageInspectionSchema; delivery in createEvidenceToolHandler.

  • 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:

    • Breaking for MCP callers that omit detail on captures above 32 KiB: they receive the summary. Pass detail: "complete" for the previous shape.
    • rea inspect-web-page prints the complete capture when --detail is omitted or complete. --detail summary requires --evidence_output and prints the summary with the bundle receipt, like analyze-web-bundle. Before this PR the generated --detail option 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_view or detail: "complete". detail is 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.ts runs through MCP against the fake CDP browser:

    • 400 console events with omitted detail return the summary, with counts by type;
    • console pages filter by type and page by offset;
    • detail: "complete" returns the capture without detail in its parameters;
    • a 2-event capture stays inline.
  • tests/boundary/cli/browserCli.test.ts: --detail summary without --evidence_output fails, and with it prints the summary.

  • Real provider: Chromium 156 on Linux (table above).

  • Remaining proof gaps:

    • No client trials. Token savings are inferred from sizes.
    • Linux only.
  • 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 use inspect_web_page or analyze_web_bundle, plus the analysis-view, contract and server suites: 166 files; 3,420 passed, 3 skipped. The 2 failures were the separate analyze_web_bundle delivery expectation fixed in its own PR.
  • npm run verify:advertised-schemas (summary updated), npm run docs:check and npx tsc --noEmit -p . passed.

Compatibility, safety, and release

  • Breaking changes or migration steps: pass detail: "complete" to keep complete delivery for large captures.
  • Real Hopper/Ghidra, browser, or OS coverage: Chromium 156, Linux.
  • Package or release metadata impact: advertised schema for inspect_web_page.
  • Security, privacy, process, or containment review: pages project already-captured, already-redacted fields; no new capture.

Author readiness

Human owner: exempt maintainer account (N0zoM1z0) per CONTRIBUTING.md; readiness boxes left for the human owner.

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

…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]>
@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

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

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-24T12:25:10.294380Z
We couldn’t complete this review. Comment @codex review to try again.
2b3565a PR opened
ℹ️ 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.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@greptile-apps

greptile-apps Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: plus

[Medium impact] The reviewed changes appear safe to merge; no new actionable issue remains.

Summary

Adds size-aware delivery for inspect_web_page, retained section pages, and CLI summaries backed by an Evidence bundle.

  • Large page captures return a summary unless callers ask for the complete capture.
  • Retained browser captures can be browsed one section at a time.

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]
Loading

Reviews (4) · Last reviewed commit: "test(browser): request complete captures..." · Reviewed by Greptile

Comment thread src/domain/analysisView/webPageView.ts Resolved
Comment thread src/domain/analysisView/webPageView.ts Resolved
Comment thread src/domain/analysisView/webPageView.ts Resolved
gensokyo-dev and others added 3 commits November 24, 2026 12:31
…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]>
@morluto
morluto merged commit 67a1e2c into main Nov 24, 2026
55 checks passed
@morluto
morluto deleted the feat/web-page-view branch November 24, 2026 15:08
morluto added a commit that referenced this pull request Nov 25, 2026
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.
@morluto

morluto commented Nov 25, 2026

Copy link
Copy Markdown
Owner

Follow-up in #14252: the size decision this PR added for inspect_web_page is now made by the agent result budget, delivery.agent_result_budget_bytes.

  • What stays. The web-page section views, inspect_web_page keeping detail out of the capture, the summary from feat(browser)!: size inspect_web_page delivery and page captures by section #14368, and the rule that only a session advertising inspect_analysis_view gets a summary.
  • What changes. The fixed 32 KiB bound (SIZE_AWARE_INLINE_EVIDENCE_BYTES) and analysisDetailSizeAwareSchema are replaced by that setting. Its default is also 32,768 bytes, so the default behavior is the same. It now also follows update_analysis_settings and the REA_AGENT_RESULT_BUDGET_BYTES launch seed.
  • Over-budget results. They also carry delivery facts: the budget, the complete size, and an evidence-json cursor.
  • Tests. The web-page view tests from this PR run unchanged, with budgeted delivery.
  • Verifiers. The explicit detail: "complete" added to the four real-browser verifiers is no longer needed, because their clients now request complete Evidence through scripts/lib/complete-evidence.mjs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: runtime Process capture and runtime observation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants