Repository navigation
fix: inject readImage result once and strip base64 from tool message - #1306
Merged
Merged
Conversation
Owner
Author
Audit ResultsGoal FulfillmentAll three goals from issue #1305 are satisfied:
Spec ComplianceThe implementation matches the delta spec for
Task CompletionAll 8 tasks in Quality Check
|
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.
Description
Implements the image-dispatch inject-once fix. The
ImageDispatchmiddleware now injects areadImageresult only once — tracked bytool_call_idin a closure-levelSet— so the image is attached on the turn immediately following the call and never re-attached to unrelated subsequent prompts. It pairs the image with the prompt that triggered thereadImagecall (the HumanMessage preceding the AIMessage that made the call) rather than the most recent user prompt, and strips the base64 payload from thereadImageToolMessage content by replacing it with a stubToolMessage("Image read successfully.") so the model never receives it as plain text tokens. The replacement message list is built without mutating the persisted state objects thatrequest.messagesshares with the checkpointer.Type of Change
Testing
Added regression tests in
tests/unit/provider/imageDispatchMiddleware.test.jscovering: base64 payload stripping from the ToolMessage content, pairing the image with the triggering prompt (not the most recent one), and inject-once behavior (no re-attachment to a later unrelated prompt). All 12 tests intests/unit/provider/imageDispatchMiddleware.test.jspass.npm run lintpasses with 0 warnings and 0 errors.npm run coveragereportsimageDispatchMiddleware.jsat 96.00% line coverage (84.21% functions, 83.33% branches), consistent with the pre-change baseline of 96.26%. Note: the fullnpm run coveragerun reports a pre-existing, unrelated failure intests/unit/tools/web.test.js(web tool default search engine config) that also fails onmainand is not touched by this change.Coverage
Checklist
npm run lintpassesCloses #1305