preview_snapshot includeImage embeds full-res base64 PNGs into tool history; providers that reject inline images brick the session permanently
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 23k
- Forks
- 5.9k
- Avg merge
- 11h 14m
- Merged PRs (30d)
- 357
Description
Problem
t3-code_preview_snapshot with includeImage:true embeds full-resolution base64 PNG data: URLs directly into the MCP tool result (state.attachments). Those bytes persist in agent session history and are replayed to the model provider on every subsequent request.
Some providers reject inline image uploads. Observed case: opencode.ai zen gateway → upstream Console, model muse-spark-1.3-contributor-free, returns non-retryable 400 invalid_request_error: Invalid upload request on all later requests — including trivial text-only prompts. The session is permanently bricked; only surgery on the session store (deleting the attachments) recovers it.
Concrete numbers from the incident: two snapshots produced ~1.35MB + ~50KB base64 attachments (1280×800 PNGs), taking session tool history to ~2MB.
Requests
- Downscale/compress screenshots before attaching (e.g. max-width + JPEG quality params on the snapshot tools), so the common case stays small.
- Prefer returning a file path / saved-file reference plus text over inline base64, letting the agent re-read the image only when vision is actually needed.
- Default
includeImageto false (or document text-first usage) so agents don't attach images unless the task needs them.
Related upstream tracker (provider-side rejection): https://github.com/anomalyco/opencode/issues/47237 — this issue is the T3-side mitigation for it.
Built from a real incident diagnosed via Muse Spark through T3 Code.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the t3-code_preview_snapshot tool and trace how includeImage populates state.attachments and persists into agent session history. Reproduce the large base64 data URLs described in the incident, then compare the available mitigation requests: resizing or compressing images, returning saved-file references, and changing the includeImage default. Done means later text-only requests no longer inherit provider-rejected inline images.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100