fix(server): a full Claude context window no longer shows as a usage limit #19848
main fromrefs/pull/19848/head·merged by juliusmarminge View on GitHubProblem#
When a Claude conversation fills its context window, the turn ends with terminal_reason: "blocking_limit", result: "Prompt is too long". T3 Code shows "Usage limit reached" with "Reset time unavailable; retry manually", even though the latest rate_limit_event is allowed. Retrying can never work, and the user is not pointed to /compact or a new thread. Fixes #19832.
Change#
ClaudeAdapterV2 treated every blocking_limit as a usage limit. It is now a usage limit only with rate-limit evidence: api_error_status 429, a rejected rate_limit_event, or a rate_limit assistant error. Otherwise the turn fails as a provider_error saying the context window is full, with /compact or a new thread as the way out. A genuine usage-limit blocking_limit now shows the existing "usage limit reached, send again once the limit resets" hint instead of "a usage limit blocked the request". Clients key off failure.class, so no client or contract changes are needed.
Scope and approval#
A small, focused fix for an obvious misclassification, from the reproduction in #19832 (provider log included). It changes no settings, schemas, defaults or recovery policy. #19414, #19543 and #19583 are adjacent but do not cover this classification.
Verification#
vp test run src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts(inapps/server): 258 passed. A new table test replays the issue's frames. With the fix reverted, the allowed-window case fails withusage_limit.- Controls: a rejected five-hour window still yields
usage_limit. The existing table test now expectsprovider_errorforblocking_limitwithout evidence. vp fmt --checkis clean.vp linton both files shows 0 errors and 1 existing warning. Theapps/servertypecheck passes.- Not checked: a live Claude run at a full context window, since this is a frame replay. No repo-wide checks were run.
Model: Claude Sonnet 5.5. Harness: Claude Code in T3 Code.
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:S
Approvability#
Verdict: Approved at
c6bb998Macroscope's review found this PR approvable — This is a narrowly scoped Claude error-classification fix with targeted regression coverage. It changes only the user-facing handling of an existing terminal result and preserves genuine usage-limit behavior without affecting schemas, defaults, or deployment.
You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
-
⚙️ Run configuration
-
- Configuration used: Path: .coderabbit.config.ts
- Review profile: CHILL
- Plan: Advanced
- Run ID:
5278da87-cb39-47f0-93dd-e5330f2545f0
📥 Commits
-
Reviewing files that changed from the base of the PR and between 339179f50a84dc599cce373dbb48f172f182f44e and c6bb9980bf534fe912bfc02018182844b3259356.
📒 Files selected for processing: 2
-
apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.tsapps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
-
📝 Walkthrough
-
Claude terminal failures now use context-window messaging for
blocking_limitandprompt_too_long. Usage-limit classification relies on API status 429 or explicit usage-limit evidence. Tests cover allowed and rejected five-hour rate-limit windows.Changes: Claude terminal failures
Layer / File(s) Summary Terminal failure mapping and tests
apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts,apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.tsblocking_limituses a context-window message unless a failure hint is present.prompt_too_longuses the same message. The adapter classifies usage limits based on API status 429 or usage-limit evidence. Tests coverblocking_limitwith allowed and rejected five-hour rate-limit windows.Priority: ➖ Normal
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix · Severity of issue fixed: Medium
Suggested reviewers:
juliusmarminge
Merge Risk: ⚪ Minimal · up to
c6bb9-
The reviewed change distinguishes context-window failures from rejected rate limits. No issue requiring a fix before merge was identified.
Pre-merge checks:
4-
Passed checks: 4 passed-
Check name Status Explanation Title check The title clearly and concisely describes the main fix: Claude context-window failures no longer appear as usage-limit errors. Description check The description includes the problem, change, scope and approval rationale, linked issue reference, focused verification results, controls, and unchecked live-run limitations. It is complete and align… Linked Issues check Issue #19832requiresblocking_limitto useusage_limitonly with rate-limit evidence. The adapter now removesblocking_limitas an independent usage-limit condition. It returns the context-wind…Out of Scope Changes check The diff changes only ClaudeAdapterV2classification and user-facing error text, plus focused adapter tests and test-frame support. These changes directly implement issue#19832. No unrelated settin…
-
✨ Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
-
juliusmarminge merged thisfb9af9e
juliusmarminge closed this
Sign in to join this conversation.
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes