fix: recognize Codex context-overflow errors and learn conservative window when unparseable - #281
Merged
Merged
Conversation
…indow when unparseable closes #280 After a macOS sleep/wake (or any rebind), a restored session starts with lastInputTokens=0, so the nudge is blind and only the preflight fit check can catch an oversized replay. Two gaps left the Codex path stuck: - Codex's overflow error (code context_window_exceeded / "ran out of room in the model's context window") matched none of CONTEXT_OVERFLOW_PATTERNS, so no self-heal ever armed and the same oversized payload was re-sent forever. - Even when the error is recognized, Codex's body carries no window number, so parseOverflowWindow found nothing and the floor stayed 0. Now: both Codex markers are recognized, and when no window is parseable the proxy learns a conservative window from the rejected payload's own size (only-shrink-never-grow). The next turn's self-heal re-centers the limit and preflight compresses the history below it before forward. Tests: 2 unit (Codex error recognition) + Codex e2e self-heal (400 without window number -> learned window -> preflight fold on the retry) + new Responses-protocol e2e for the issue's suggested restore scenario (fresh session, lastInputTokens=0, raw history over the window -> preflight compresses before forward). Full suite: 661/661 pass.
📦 Built Package ArtifactBranch: Option A — Install from npm PR tag (recommended)npm install -g billion-context@pr-281Each push to this PR publishes a new version under the Option B — Download artifact
tar xzf billion-context-pr281.tgz
npm install -g packageThis comment is automatically updated on each push. |
This was referenced Aug 27, 2026
Merged
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 #280
Background
After a macOS sleep/wake (or any rebind), a restored session starts with
lastInputTokens=0. The nudge is blind at tokenCount=0, so only the preflight fit check can catch an oversized raw-history replay. The preflight safety net (shipped in v0.1.57 via #247) already covers the main path — but two gaps left Codex sessions stuck:context_window_exceeded/ "ran out of room in the model's context window" — neither matchedCONTEXT_OVERFLOW_PATTERNS, so no self-heal ever armed and the same oversized payload was re-sent forever.parseOverflowWindowfound nothing and the armed floor stayed 0.Changes
src/util.ts: recognizecontext_window_exceededand the "ran out of room in the model's context window" phrasing as context overflow.src/server.ts: when an overflow is recognized but no window is parseable, learn a conservative window from the rejected payload's own size (only-shrink-never-grow). The next turn's self-heal re-centers the limit and preflight compresses the history below it before forward.Tests
Full suite: 661/661 pass.
🤖 ework agent