Skip to content

fix(read): gate image attachment on model multimodality and size (#181) - #278

Open
innocarpe wants to merge 1 commit into
lessweb:mainfrom
innocarpe:fix/181-read-gating
Open

fix(read): gate image attachment on model multimodality and size (#181)#278
innocarpe wants to merge 1 commit into
lessweb:mainfrom
innocarpe:fix/181-read-gating

Conversation

@innocarpe

Copy link
Copy Markdown

Summary

  • The read tool only attaches image content (base64) to the conversation history when the active model supports multimodal input, and skips files above a size cap.
  • Text-only models no longer accumulate megabytes of base64 in history, preventing context overflow (HTTP 400) on session resume.

Why

The read tool 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 on supportsMultimodal(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

…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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

read tool inlines PDFs/images as base64 into history → context overflow (HTTP 400) on text-only models

1 participant