fix(read): gate image attachment on model multimodality and size (#181) - #278
Open
innocarpe wants to merge 1 commit into
Open
fix(read): gate image attachment on model multimodality and size (#181)#278innocarpe wants to merge 1 commit into
innocarpe wants to merge 1 commit into
Conversation
…sweb#181) Only attach base64 image content to the conversation history when the active model supports multimodal input, and skip files above a size cap. Text-only models no longer accumulate megabytes of base64 in history, which previously led to context overflow (HTTP 400) on session resume. (cherry picked from commit 45ec1dc9e9a28252919fb65715aa8fa1f9e0a7a1)
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.
Summary
readtool only attaches image content (base64) to the conversation history when the active model supports multimodal input, and skips files above a size cap.HTTP 400) on session resume.Why
The
readtool inlined whole image files as base64 data-URIs into history regardless of the model. On text-only models (e.g.deepseek-reasoner) each image added hundreds of thousands of tokens to the stored history; after a few reads or a resume, requests exceeded the context window and hard-failed with 400. Request-time filtering already existed, but the history itself still grew unboundedly.Changes
packages/core/src/tools/read-handler.ts: gate image attachment onsupportsMultimodal(model)and a 15 MB size cap; return a clear notice instead of attaching when gated.packages/core/src/tests/read-handler.test.ts: tests for text-only (no attach) and multimodal (attach) models.Validation
npm run typecheck✅npm test— new read-handler tests pass ✅Closes #181