Skip to content

Don't replay image attachments to models without image input - #98

Open
hmk wants to merge 1 commit into
cloudflare:mainfrom
hmk:fix/image-replay-locks-chat
Open

Don't replay image attachments to models without image input#98
hmk wants to merge 1 commit into
cloudflare:mainfrom
hmk:fix/image-replay-locks-chat

Conversation

@hmk

@hmk hmk commented Aug 9, 2026

Copy link
Copy Markdown

Sending an image attachment to a model without image input fails with the provider's 400 — and because history replay rebuilds the model request from the chat log on every turn, the image is re-sent on every subsequent message, permanently wedging the chat.

This gates the image content part on the model's declared input modalities (model.input), degrading to the existing [Attached file … omitted] text marker instead — the same path other unsupported attachment types already take. PDFs get the same gate since they ride an image content part. The conversion is extracted into chat-attachment-parts.ts with tests, following the existing chat-attachment-validation.ts / chat-attachment-pdf.ts pattern.

Since replay rebuilds from the log each turn, chats that are already stuck recover on their next message.

Known limitation: custom/uncatalogued models default to input: ["text", "image"], so a text-only custom model can still hit the 400. Discussion of how to handle that is on the issue.

Fixes #97

History replay converted image attachments to image content parts
unconditionally, so an image sent to (or a chat later switched to) a
model without image input made every request 400 with the provider's
"does not support image input" error -- permanently wedging the chat,
since replay re-sends history on every turn.

Extract the attachment-to-content-parts conversion into
chat-attachment-parts.ts (following chat-attachment-validation.ts /
chat-attachment-pdf.ts) and gate the image part on the model's declared
input modalities, degrading to the existing omitted-file text marker
otherwise. PDFs take the same gate, since they ride an image content
part (see chat-attachment-pdf.ts). Because replay rebuilds from the log
each turn, already-wedged chats recover on their next message.

Claude tracked down the replay path and wrote the fix and tests.
@github-actions

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@hmk

hmk commented Aug 9, 2026

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

github-actions Bot added a commit that referenced this pull request Aug 9, 2026
@hmk

hmk commented Aug 9, 2026

Copy link
Copy Markdown
Author

for posterity: this PR was built with the assistance of Claude Code and Fable 5

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.

Image attachment sent to a non-vision model permanently locks the chat

1 participant