feat(screenshot)!: default to a 1024px JPEG for agent-facing captures - #185
Merged
Merged
Conversation
A screenshot is the heaviest single response an agent can request: a 1920x1080 PNG bills at roughly 2,040 image tokens, against about 576 for the same frame capped at 1024px. The lightweight options existed but were opt-in, so the common caller paid full price for fidelity no vision model can use. `screenshot` now defaults to JPEG quality 75 capped at 1024px wide. Three rules keep that from surprising anyone: - an explicit `--format` always wins; - with no `--format`, a `--path` ending in `.png` selects PNG — writing JPEG bytes into a file the caller named `.png` is a worse outcome than the tokens the default saves; - an explicit `--width`/`--height` suppresses the cap. That gate predates this change, which is why sized captures do not silently shrink. `--max-width 0` is the opt-out for the cap alone and travels as a -1 wire sentinel, because `maxWidth == 0` already means "unspecified" and the wire model cannot carry a nullable int. ScreenshotDefaults lives in Runtime/Protocol so the CLI and the bridge resolve the defaults from one place and the resolution is unit-tested; resolving the cap once in Handle also collapses the ShouldApplyMaxWidth gate that was repeated at each capture site. Protocol 7 -> 8: the default output of an existing command changed and maxWidth gained a sentinel, so a mismatched CLI should be routed to a matching install rather than silently return different images. Verified live against the sample project (Unity 6000.3.13f1, headless): with the Game View at 3600x2110, an option-free capture returned 1024x600 jpg / 10 KB against 3600x2110 png / 104 KB before. Format selection, the .png path rule, the explicit-size bypass and the negative --max-width rejection all confirmed against a running editor. Closes #127 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #127
Why
A screenshot is the heaviest single response an agent can request. A 1920×1080 PNG bills at roughly 2,040 image tokens; the same frame capped at 1024px is about 576.
--format jpg,--qualityand--max-widthalready existed, but they were opt-in, so the default caller paid full price for fidelity no vision model can use.What changed
screenshotnow defaults to JPEG quality 75, capped at 1024px wide. Three rules keep the new default from surprising anyone:--format png|jpg|jpeggiven--format,--pathends in.png.pngis worse than the tokens saved--widthand/or--heightgiven--max-width 0--max-width 0was previously rejected (minimum 1); it is now the documented opt-out and travels as a-1wire sentinel, becausemaxWidth == 0already means "unspecified" and the wire model cannot carry a nullable int.QA coordinates are unaffected:
qa tap/ui-dump/world-dumpscale fromLastCapturedWidth/Height, so a downscaled capture's coordinates still land.Structure
ScreenshotDefaultslives inRuntime/Protocol/so the CLI and the bridge resolve the defaults from one place and the resolution is unit-testable (Editor/*.csis not compiled bydotnet). Resolving the cap once inHandlealso collapses theShouldApplyMaxWidthgate that was repeated at every capture site — that is most of the −59/+? churn in the handler.Protocol 7 → 8
The default output of an existing command changed and
maxWidthgained a sentinel. Bumping means a CLI that does not know the new defaults is routed to a matching install instead of silently returning different images. No response shape changed.Verification
dotnet test— 1087 passed (17 new).check-unity-meta.shpasses; the new.cshas a Unity-generated.meta.DocGen --checkclean.Live against the sample project (Unity 6000.3.13f1, headless launch):
1024x600jpg — cap fired on a 3600×2110 Game View--format png --max-width 03600x2110png--path x.png, no--format--format jpeg --quality 40--width 1600 --height 9001600x900, cap suppressed--max-width -1CLI_USAGErejectionRelease note
This is a breaking default change plus a protocol bump, so it wants a minor version (0.6.0), and the CLI binary must be published before
mainmoves — a user on#mainwith no CLI speaking protocol 8 would have nothing to dispatch to.🤖 Generated with Claude Code