PR #10182 review: Claude model limit account switch
Summary
When Claude refuses a turn with a per-model limit ("You've hit your Fable limit"), the turn now counts as a usage limit and not a generic error. The user gets the composer notice with the account pill and Resume. The ACP adapter now reads the JSON-RPC error.data (rateLimit, errorKind) and Claude Code's own USAGE_LIMIT_ERROR_PREFIXES. The generic wording check now accepts named limits. On the desktop, the account pill and menu move into a shared UsageAccountMenu, which the usage-limit failure card also shows now.
Verdict
minor issues The approach is sound: structured data comes first, and the CLI's wording is gated on errorKind in the ACP path. Two wording checks are wider than the PR's own tests say they should be.
Findings
packages/chat-runtime/src/harness/claude/translateStream/translateStream.ts:391: the direct Claude harness calls isClaudeUsageRefusal(text) with no errorKind gate. In the ACP path, isClaudeUsageError adds that gate. The SDK prefixes include the broad "You've hit your" and "You've reached your". So any is_error result that starts with them becomes a usage limit. That includes "You've reached your maximum context length", the string that usageLimit.test.ts uses as a non-limit. The new branch has no translator test.
Fix: Gate it the same way as ACP. Use a structured signal from the result envelope, such as the API error status, or require a remembered refused window. If the direct harness has no such signal, add a translateStream test that states the intended behaviour.
packages/chat/src/protocol/envelope.ts:137: the new hit your (?:(?!context|token|output|size)[\w.'-]+ ){0,2}limit is a deny-list. Non-usage limits with other words still match. This regex is shared by all agents (ACP fallback, direct harness) and by the client's classification of stored failed turns. A non-usage limit from Codex or another agent would then show "Usage limit reached" with an account switch, which can't help. Probe at the PR head:
"You've hit your tool call limit" generic: true "You've hit your maximum length limit" generic: true "You've hit your recursion limit" generic: true "You've hit your attachment limit" generic: true "You've hit your request limit for this…" generic: true "You've hit your context limit" generic: false (as intended)
Fix: Narrow the positive case, not the exclusions. For example, accept a named limit only when it has Claude's reset suffix (hit your [\w .'-]{1,30} limit\s*·), or accept only hit your (?:usage |session |weekly )?limit. Leave model-named refusals to the Claude-specific path, which already has errorKind.
packages/chat-runtime/src/harness/usageLimit/usageLimit.ts:1: the ACP adapter now imports a value from @anthropic-ai/claude-agent-sdk to get one string list. Before, only the direct Claude adapter loaded it. The package is already a dependency, so this is not a problem today. It does link Codex/other ACP sessions to SDK upgrades: a renamed or removed export breaks the shared harness. No change needed unless you prefer to keep ACP free of the SDK.
Structure, AGENTS.md and i18n: no problems found. UsageAccountMenu lives in ChatSession/components/ because both SessionView and TurnFailureCard use it. This follows the "highest shared parent" rule. The moved strings did not change, and check:i18n left the tree clean. No tRPC procedure changed. The wire change only adds an optional data field.
Evidence
| Surface | Result |
|---|---|
| Desktop (composer notice, failure card, account menu) | Not verified. I started apps/desktop with RENDERER_REMOTE_DEBUG_PORT=9333 bun dev against the running local API (:3001). The renderer target at localhost:3005/#/ came up, but the window was still black. Then bun dev was OOM-killed (exit 137) in this 8 GB sandbox. Desktop tsc was OOM-killed here too. Also, the changed states need a real Claude login at its model limit, or a stored failed turn, and this sandbox has neither. I did not use a shim. |
| Runtime classification (chat-runtime / chat) | Verified with unit tests and a probe script at the PR head (see the table above and the CI notes). |
| Mobile, Codex sessions | Not run. The PR also leaves these out. |

Questions for the author
- In the direct Claude harness, does an
is_errorresult ever carry text that starts with "You've reached your…" or "You've hit your…" but is not a usage refusal? If not, write that in a test, so the different gating from ACP is clearly intended. - The generic regex changed for all agents. Was it checked against Codex or Gemini wording for non-usage limits (tool calls, request size)?
- When a stored usage-limit card is the latest turn and the composer notice also shows, the pane renders two account pills. Is that expected?
Test / CI notes (at d9556e30)
bun testinpackages/chat: 133 pass. Inpackages/chat-runtime: 552 pass, 2 skip, 0 fail. In the desktopChatSessionfolder: 526 pass.tsc --noEmitforchat-runtime: clean. Desktoptsc: OOM-killed locally (exit 137, 8 GB). The CI Typecheck job is the source of truth.biome checkon the 20 changed files: clean.bun run check:i18n: passed, no catalog changes.- GitHub checks: Lint, Typecheck, Test, Sherif, Version Sync, CLI build and previews all passed. CodeRabbit was still pending when I checked.