Repository navigation
Do not retry a context overflow reported as a server error - #207
Open
Will Walker (willswire) wants to merge 1 commit into
Open
Will Walker (willswire) wants to merge 1 commit into
Will Walker (willswire) wants to merge 1 commit into
Conversation
Some Chat Completions servers report an overflow as a server error:
Apple's `fm serve` answers HTTP 500 ("The session's transcript exceeded
the model's context size."), or sends that error inside the stream after
HTTP 200. Both were retried, resending the whole conversation each time
(against a daily quota on fm's PCC model), and the turn then failed as
a generic server error.
The message is now recognised as an overflow, both retry paths stop on
an overflow, and the turn ends once as context_full. Nothing is trimmed
or compacted unless compaction is turned on.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Will Walker (willswire)
requested a review
from Zezi Zeng (ClarenceStark)
as a code owner
December 6, 2026 14:12
|
Thanks for the pull request! A few friendly reminders based on the files changed:
(This comment updates automatically when you edit the PR description or push new commits.) |
Author
|
@microsoft-github-policy-service agree |
5 tasks done
This branch has not been deployed
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.
Linked issue
Fixes #205
What changed (Before / After)
fm serveanswers HTTP 500 with "Thesession's transcript exceeded the model's context size.", or sends that error inside the stream after HTTP 200)
was retried like a temporary failure. Each retry resent the whole conversation, and the turn finally failed as
"the server is failing".
the turn ends once as context full, with the window when it is known. Nothing is trimmed or compacted unless
compaction is turned on. The change applies only to errors whose text already says the context overflowed.
Visual proof (UI / TUI / Web / Desktop / export changes)
N/A (runtime only).
How you verified it
test_apple_fm_overflow_is_context_full_and_not_retriedintests/test_context_window.py: a fake Chatserver replays both shapes
fm serveproduced on macOS 27.2.1 (HTTP 500 JSON, and an in-streamevent: error)and checks the turn ends as
context_fullafter exactly one request.uv run pyflakes src tests .github/scripts;tests/test_context_window.pyandtests/test_compaction.pypass;the Python 3.9 import check for
src/freehand/runtime/passes.test_snapshots. I believe that failure comes from my local gitcommit-signing setup, not from this change; the rerun with signing off was interrupted, so this is not
confirmed yet.
fm serve, the overflow error was confirmed for both shapes before the fix was written.AI disclosure & checklist
uv run pyflakes src tests .github/scriptsprints nothing and relevant tests pass locally (full suite runs in CI)CHANGELOG.mduntouched (maintainers update it at release time)src/freehand/runtime/still uses only the standard library and imports on Python 3.9🤖 Generated with Claude Code