Skip to content

fix(server): bound preview snapshot metadata - #7408

Closed
devhims wants to merge 1 commit into
pingdotgg:mainfrom
devhims:fix/bound-preview-snapshot-output
Closed

fix(server): bound preview snapshot metadata#7408
devhims wants to merge 1 commit into
pingdotgg:mainfrom
devhims:fix/bound-preview-snapshot-output

Conversation

@devhims

@devhims devhims commented Aug 18, 2026

Copy link
Copy Markdown

Problem

preview_snapshot forwards Chrome's full accessibility tree to the provider. On large pages, this can add hundreds of kilobytes of JSON to one tool result and consume most of the thread's context window.

Fix

Cap snapshot metadata at 64 KB. If it exceeds the limit, omit the accessibility tree and mark the result as truncated. If the remaining fields are still too large, return a compact page summary. Normal snapshots are unchanged.

Added a regression test that sends an oversized snapshot through the MCP tool and verifies that the returned metadata stays within the limit.

Validation

  • vp test run apps/server/src/mcp/McpHttpServer.test.ts
  • vp run --filter t3 typecheck
  • Targeted lint and formatting checks

Implemented with GPT-5 via Codex desktop.

Note

Bound preview snapshot metadata to 64,000 bytes in preview_snapshot tool

  • Adds a previewSnapshotMetadata helper in McpHttpServer.ts that serializes snapshot metadata (excluding screenshot data) and truncates it if it exceeds 64,000 bytes.
  • When over the limit, it first drops accessibilityTree and marks truncation with reason metadata_size_limit; if still over, it falls back to truncating strings (visibleText to 8,000 chars, URL/title) and clearing list fields.
  • The preview_snapshot handler now uses this helper for both the text content (serialized JSON) and structuredContent (bounded metadata object).
  • Behavioral Change: oversized snapshot responses will now be truncated with truncation metadata rather than returned as-is.

Macroscope summarized 3cdc4c5.

@coderabbitai

coderabbitai Bot commented Aug 18, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: c8af7b0b-054e-429a-b1f6-470394f1cc1b

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Aug 18, 2026
@devhims
devhims marked this pull request as ready for review August 18, 2026 14:46
@macroscopeapp

macroscopeapp Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Not approved

Macroscope's review found this PR not approvable — This is a straightforward defensive fix that bounds preview snapshot metadata to 64KB with progressive truncation. The logic is clear and well-tested, but the author is a first-time contributor to this codebase, warranting human verification of the truncation approach.

You can add or adjust custom eligibility rules. Learn more.

@t3dotgg

t3dotgg commented Sep 4, 2026

Copy link
Copy Markdown
Member

Note

🤖 GPT-6 Astra (preview) responding on behalf of Theo

This was closed as part of an automated cleanup pass. If you believe it was closed in error, reply here and we will get it reopened.

Closing in favor of #9505, the retained snapshot-size fix. It declares truncation in the contract and keeps interactive locators longer. Its latest code also caps title and URL, so this branch adds no unique limiter behavior. Review continues there.

@t3dotgg t3dotgg closed this Sep 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants