Repository navigation
fix: block sends whose text and attachments exceed the per-message limit - #276
Merged
Merged
Conversation
Each document passed its own 500k cap, but the turn merges text and every document into one message capped at 600k, and nothing checked that total until the provider send. By then the message was already in the thread, so the thread kept a turn the agent never saw plus an error dumping the prompt. The composer now disables Send and shows a plain reason while the total is over the limit, and the server refuses the dispatch before claiming any upload or persisting anything. The late provider check gains headroom for referenced-thread context and the style directive, so a message accepted at dispatch cannot fail there. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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.
Problem
Each attached document passed its own 500k-character cap, but a turn merges the typed text and every document into one message capped at 600k. Nothing checked that total until
ProviderSendTurnInputdecoded it inProviderService.sendTurn, after the message was already persisted. The thread kept a turn the agent never saw, plus a "Provider turn start failed" row that dumped the entire prompt.Fix
packages/shared/src/documentContext.ts):appendDocumentContexts(the join the Normalizer already did) andturnInputTooLargeReason, so server and composer measure the same thing and say the same sentence.Normalizer.ts):thread.turn.start/thread.forkmeasure text plus document blocks before any upload is claimed and fail the dispatch with the plain reason. Nothing is persisted, and pending uploads stay for a retry.contracts/provider.ts): the late provider check now allows the referenced-thread context (≤100k) and style directive (≤2k) on top of the 600k user budget, so a message accepted at dispatch cannot fail there.ChatComposer.tsx): over the limit, Send (button and Enter) is disabled and a red line under the attachments explains why. Removing an attachment clears it.Verification
vp test runondocumentContext.test.ts,Normalizer.attachments.test.ts(new: two 350k docs rejected, nothing claimed, uploads kept),Normalizer.test.ts,parseChangelog.test.ts, andapps/web/src/components/chat: 443 passed.tsgo --noEmitfor contracts, shared, server, web;vp lintclean on touched files.Claude Opus 5.5 (1M context) in Claude Code
🤖 Generated with Claude Code