Repository navigation
fix(coderd/x/chatd): close three view_image follow-ups from the #250 review - #382
Conversation
…review An animated WebP now fails like an animated GIF: a VP8X header with the animation flag or any ANMF chunk makes the tool reject the file, so a stored result cannot fail every later request on OpenAI. The prompt bound no longer exempts the newest viewed image from the image count. A prompt that already holds maxImagesInPrompt other images drops every viewed image instead of going over Anthropic's 20 image threshold. The newest one still ignores the byte budget alone, so a single large view stays visible. The viewed-image bound follows the turn's custom agent tool policy. A dynamic view_image that the policy drops no longer owns the name, so the bound applies; one the policy keeps still owns it. The policy resolves before the appendForkTools hook in buildTurnEnvironment, and the compaction path gets the same policy through generationCompaction. Closes #291.
@codex review |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 96eceb22cf
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…olicy filter Codex review of 96eceb2 found that the new policy check in dynamicToolOwnsViewImage diverged from customAgentToolPolicy.filter: a policy with Tools nil kept a dynamic view_image in the tool list, but the check dropped it and bounded its images; a policy that kept it in Tools but dropped it through read_only or disallowed_tools kept ownership while the tool was gone. A shared keepsDynamicViewImage decision now serves both paths. The gate test covers read-only and disallowed_tools policies. An architecture TODO records the changed count bound and the policy ownership for the human owner.
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 19f932657b
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
@codex review The two threads of the previous review are fixed (19f9326) or answered (the architecture TODO is required by AGENTS.md L75-76 and by the earlier finding 4601899025, and stays for the human PR author). Both are resolved. |
|
Codex Review: Didn't find any major issues. 🎉 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
… into the architecture bullet Per the lead decision since 2026-11-16, fork PRs write final prose in the fork-owned architecture sections instead of leaving TODO comments. The TODO is gone: the fork-view-image bullet now states that the newest viewed image alone ignores the 10 MiB byte budget but still drops while other images fill the 20-image count, and that while fork-view-image is off the dynamic view_image owns the bound only when the chat's custom agent tool policy keeps it, through dynamicToolOwnsViewImage and customAgentToolPolicy.keepsDynamicViewImage.
@codex review ed41291 removes the architecture TODO and writes its content as final prose into the fork-view-image bullet, per the lead maintainer's standing decision that fork PRs update the fork-owned ARCHITECTURE.md sections directly (precedent PRs #272, #278, #281, #363, #366). |
|
Codex Review: Didn't find any major issues. Keep it up! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Merged at head Gates on this exact head:
Tests I ran on
Review notes:
Not exercised:
|
Closes #291.
Three follow-ups from the #250 review of
fork-view-image. All fork logic lives infork_*.gofiles behind the existingfork-view-imageexperiment. No new dependency. No changes outsidecoderd/x/chatd.Fixed
1. Animated WebP is rejected
viewImagenow walks the RIFF container of aimage/webpfile and rejects it when it finds anANMFframe chunk or aVP8Xchunk with the animation flag bit set. Error text tells the model to save one frame as a PNG. SeewebpAnimatedincoderd/x/chatd/fork_view_image.go. The tests build minimal WebP byte streams in the test file, so no fixture or decoder is needed.2. The image count bound now counts every other image
limitViewedImagesused to exempt the newest viewed image from all bounds. It keeps that byte-budget exemption, but it no longer escapes the count:kept < maxViewedImagesInPromptandotherImages+kept < maxImagesInPromptnow apply to the newest image too. Twenty other images plus two viewed images now drop both viewed images, where before the newest one stayed in the prompt.3. Bound ownership follows the custom agent tool policy
The view_image limit logic decided ownership from the chat's dynamic tools before the custom agent tool policy filtered them, so a dynamic
view_imagethat the policy dropped still kept its images unbounded.turn_environment.gonow resolves the policy beforeappendForkToolsand passes it in through a newforkToolsWithCustomAgentPolicyoption.dynamicToolOwnsViewImagetakes the policy and returns false when the policy allowlist leaves the tool out. The compaction path receives the same policy throughgenerationCompaction, so a compaction override model cannot re-expand the prompt.Declined from #291, with reasons
Tests
New tests in
coderd/x/chatd/fork_view_image_internal_test.go:TestViewImageTool/AnimatedWebP: VP8X-flag and ANMF files are rejected with the animated error, a still VP8X file is accepted.TestLimitViewedImages/OtherImagesFillTheCount: 20 other images plus 2 viewed drops both viewed images; 19 other images keeps the newest.TestViewImageToolGate/OffWithDynamicToolDroppedByPolicyand/OffWithDynamicToolKeptByPolicy: withfork-view-imageoff and a dynamic view_image, a policy allowlist without the tool bounds the images, one with the tool leaves them unbounded.Commands run, each under
flock ~/.fork-go.lock:go test ./coderd/x/chatd/ -count=1: PASS, full package.golangci-lint run --config=.golangci.new-code.yaml --new-from-merge-base=origin/main ./coderd/x/chatd/: 0 issues.make gen: no working-tree changes from this PR.Negative controls
Each fix was reverted once on this exact tree and its test failed, then restored:
TestViewImageTool/AnimatedWebPFAIL (accepted/anim-x.webp).TestLimitViewedImages/OtherImagesFillTheCountFAIL (newest image kept).TestViewImageToolGate/OffWithDynamicToolDroppedByPolicyFAIL (prompt not bounded).Not verified
make lint(full target) has 112 pre-existing issues onmain, including this branch's base, and its auto-fix mode rewrites unrelated files; only the scoped new-code lint was run.