Repository navigation
fix(channel): refuse attachments that can't fit the chat's model, and explain context overflows - #481
Merged
Merged
Conversation
… explain context overflows A message whose attached files exceed the model's context failed its run and every later one, since the transcript keeps it. ask and say now estimate attached files' tokens from their UTF-8 bytes and refuse a message over three quarters of the model's context window, naming the files and the limit. A run that still overflows, such as one over a message stored by 0.0.48, ends with an error that says to delete the message with the large attachment or pick a larger model. Why: packages/channel/src/room.ts#function checkContext | estimate from UTF-8 bytes, not chars; pi-ai's chars/4 undercounts non-Latin text by ~2x, which is how multilingual PDFs overflowed Why: packages/channel/src/channel.ts#function failed | overflow errors are explained in the projection, not stored, so replies already stored by older channels get the recovery hint too
This was referenced Oct 16, 2026
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.
Closes #480. Part of #26 and #5.
A message whose attached text files (or PDF text) exceed the model's context failed its run, and every later run failed the same way because the transcript keeps the message.
At send time (
packages/channel, runtime-neutral):askandsayestimate the attached files' tokens and refuse a message that can't fit. The error names the files, their size, and the limit:askchecks against the model it resolves (the requested one, the chat's current one, or the default). The check runs beforeconfigure, so a refused ask leaves the chat's model unchanged.saychecks against the chat's current model, if it has one.Recovery path: if a run fails with a context overflow (detected with pi-ai's
isContextOverflow), the reply's error now ends with: "This chat no longer fits the model's context, so every run fails this way until you delete the message with the large attachment or pick a model with a larger context." This hint is added when replies are projected to clients and is never stored. That means error replies already stored by 0.0.48 channels show it too. Deleting the message (#467) already replaces it in context. Nothing about the stored format changes.Product decisions:
Smoke-tested on an isolated host from source (temp
ACE_HOME,ACE_CONFIG_HOME, separate keychain service), with real OpenAI calls and Keynote's realLicense.pdfextracted by pdf.js the same way the app extracts it:main(3978bf0, which matches 0.0.48's behavior) and askedgpt-4o-miniabout the license text. That run overflowed, and a plain "hello" in the same chat afterwards also overflowed: the bug reproduced.gpt-4o-mini(128K),askandsayboth refused the license (432K estimated) and a 743 KB English file (248K estimated), with the errors above.gpt-4.1(1M) accepted the license and summarized it correctly.Built in Ace
Built with Claude Code outside Ace, in a session already running there; no Ace gap involved.