GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(server): bound preview_snapshot metadata sent to the agent by ylcn91 · Pull Request #9505 · pingdotgg/t3code

Conversation

@ylcn91

@ylcn91 ylcn91 commented Sep 3, 2026 •
edited by macroscopeapp Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

What Changed

packages/contracts/src/previewAutomation.ts: PreviewAutomationSnapshot gains an optional truncation field (originalBytes, omitted, trimmed) so a reduced result stays inside the tool's advertised output schema.

apps/server/src/mcp/McpHttpServer.ts: the preview_snapshot metadata handed to the agent is bounded at 100 KB by boundPreviewSnapshotMetadata. Over the limit, the title and URL are first capped at 2,048 characters (they are identifiers, and a data: URL can be the whole overrun by itself), then fields go least useful first: the accessibility tree, then the network, console, and action logs (only when they hold anything), then the visible text is cut short, and only then the interactive elements, which carry the locators the other tools need. The screenshot rides beside the metadata as an image and is never reduced. A truncated result adds a plain-language text block saying what was omitted or cut and pointing at preview_evaluate.

apps/server/src/mcp/toolkits/preview/tools.ts: the tool description says the metadata is bounded and where to look.

Tests: the reduction order and its bookkeeping on synthetic snapshots (including multi-byte text), and the tool result through the broker: bounded JSON, image kept, note present, text equal to structuredContent.

Why

Fixes #7410.

The snapshot forwarded Chrome's full accessibility tree with no limit. On content-heavy pages that alone ran to hundreds of kilobytes per tool result, enough to crowd out the thread's context; the reporter saw a later turn fail with an internal provider error once such a result entered the conversation. The producer already caps visible text (20k characters) and interactive elements (200), so the tree is the only unbounded field, and the limit is placed at the MCP boundary so every provider is covered. 100 KB sits above what the producer's own caps add up to on an ordinary page, so a snapshot without the tree is normally sent whole.

The marker lives in the contract rather than as an extra key because MCP clients may validate structuredContent against the tool's output schema, which rejects unknown properties.

#7408 proposed a fix for the same issue earlier (64 KB limit, drop the tree then fall back to a compact summary) and has not moved since mid-August. This one differs in two ways that seemed worth a separate PR rather than a comment: the truncation marker is declared in the output schema instead of added as an undeclared key, and the reduction is an ordered ladder that keeps the interactive elements for as long as possible. Happy to fold either PR into the other if a maintainer prefers.

Model and harness: Claude Fable 5.1 in Claude Code.

Note

Bound preview_snapshot metadata to 100,000 bytes in McpHttpServer

  • Adds boundPreviewSnapshotMetadata in McpHttpServer.ts to limit preview_snapshot JSON metadata to 100,000 bytes (PREVIEW_SNAPSHOT_METADATA_MAX_BYTES).
  • Oversized metadata is reduced in a fixed order: cap titles and URLs, omit the accessibility tree and diagnostics, shorten visible text, and omit interactive elements last.
  • Updates the PreviewAutomationSnapshot contract in previewAutomation.ts with an optional truncation object. The MCP response now includes an explanatory text note when metadata is reduced.
  • Risk: Behavioral change - preview_snapshot now returns truncated metadata and an extra text item when the byte budget is exceeded. Callers must check the truncation object to detect omitted fields.

Macroscope summarized d7633d8.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@ylcn91
fix(server): bound preview_snapshot metadata sent to the agent
2564fd0
@github-actions github-actions Bot added vouch:unvouched Author is not yet trusted in the VOUCHED list. size:L 100-499 changed lines (additions + deletions). labels Sep 3, 2026
macroscopeapp[bot]
macroscopeapp Bot reviewed Sep 3, 2026
View reviewed changes
Comment thread apps/server/src/mcp/McpHttpServer.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

@ylcn91
fix(server): cap the snapshot title and URL before reducing page content
d7633d8
@macroscopeapp

macroscopeapp Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Would Approve

Macroscope's review found this PR approvable — This is a focused, well-tested guardrail bug fix that bounds oversized preview metadata while preserving normal snapshots, screenshots, and interactive elements. The follow-up caps oversized URLs and titles with regression coverage; the supplied unresolved high-severity bound concern remains an independent policy block.

Not approved because:

  • 1 blocking correctness issue found at or above your repo's Minimum Blocking Severity

Adjust the Minimum Blocking Severity for this repo — including turning it Off — in Settings. You can add or adjust custom eligibility rules. Learn more.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@t3dotgg t3dotgg mentioned this pull request Sep 4, 2026
fix(server): bound preview snapshot metadata #7408
Closed
@kapiljaveri kapiljaveri mentioned this pull request Sep 5, 2026
preview_snapshot accumulates unbounded image attachments, breaking providers with per-request image limits #10187
Closed
@t3dotgg t3dotgg mentioned this pull request Sep 7, 2026
fix(mcp): keep preview snapshots usable by the agent and let it save them #10501
Merged
@juliusmarminge

juliusmarminge commented Sep 8, 2026

Copy link
Copy Markdown
Member

Superseded by merged #10501 (same preview_snapshot metadata bounds fix for #7410). Closing this leftover.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@juliusmarminge juliusmarminge closed this Sep 8, 2026
@juliusmarminge juliusmarminge mentioned this pull request Sep 11, 2026
preview_snapshot includeImage embeds full-res base64 PNGs into tool history; providers that reject inline images brick the session permanently #11295
Closed
@saphid saphid mentioned this pull request Nov 2, 2026
fix(server): preview snapshots no longer cut an emoji in half #29600
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@macroscopeapp macroscopeapp[bot] macroscopeapp[bot] left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

size:L 100-499 changed lines (additions + deletions). vouch:unvouched Author is not yet trusted in the VOUCHED list.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

[Bug]: preview_snapshot can exhaust agent context with unbounded metadata

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@ylcn91 @juliusmarminge
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.