Skip to content

fix(cli): stop framing Claude Code session limits as auth failures (KLO-734)#300

Open
kevinmessiaen wants to merge 1 commit into
mainfrom
worktree-fix+mismatching-session-limit-with-authentication-issue
Open

fix(cli): stop framing Claude Code session limits as auth failures (KLO-734)#300
kevinmessiaen wants to merge 1 commit into
mainfrom
worktree-fix+mismatching-session-limit-with-authentication-issue

Conversation

@kevinmessiaen

Copy link
Copy Markdown
Collaborator

Problem

The Claude Code auth probe (runClaudeCodeAuthProbe) wrapped every probe error as Claude Code authentication is not usable…. When the subscription hits its session limit, the user saw:

Claude Code authentication is not usable. Authenticate Claude Code locally with the Claude Code CLI, then rerun setup or the command. … You've hit your session limit · resets 10:50pm (Asia/Saigon)

That advice is wrong: auth already succeeded. Re-authenticating cannot help — only the reset clears the cap. (KLO-734)

Fix

Discriminate probe failures with a new describeClaudeProbeFailure, mirroring the existing describeCodexProbeFailure pattern in the sibling runtime:

  • Session limit (session limit / usage limit) → "Claude Code session limit reached. Wait for the reset shown…", preserving the upstream text so the reset time survives.
  • Rate limit (429 / overloaded / etc.) → "Claude Code is rate limited. Retry shortly…".
  • Otherwise → the original auth message, unchanged.

Also extended the shared CLAUDE_RATE_LIMIT_ERROR_MARKERS with the session/usage-limit phrasing so the governor's classifier (isClaudeRateLimitResult) stops treating a cap as a generic error — one source of truth, both the probe and the streaming path benefit.

Why string markers, not a typed field

The Claude Code / Agent SDK docs were checked: the session-limit phrasing is a client UI string, not a documented API error.type. In the probe path (maxTurns: 1, no governor) it arrives as free text in the result's errors[], so marker matching on that text is the correct channel. The marker is anchored on the stable session limit phrase and deliberately not broadened to loose words like "limit"/"resets", which would risk swallowing genuine auth errors.

Tests

Added three cases to claude-code-runtime.test.ts:

  • session limit → reported as a session limit, reset text preserved, not an auth failure
  • rate limit (429) → reported as a rate limit, not an auth failure
  • genuine auth failure → still reported as an auth failure (guards the marker from over-matching)

Verification

  • vitest claude-code-runtime.test.ts: 22/22 pass
  • pnpm --filter @kaelio/ktx run type-check: clean
  • pnpm run dead-code (Biome + Knip default + production): clean

🤖 Generated with Claude Code

…LO-734)

The Claude Code auth probe wrapped every error as "authentication is not
usable", so a subscription session limit told users to re-authenticate —
which cannot help, since auth already succeeded and only a reset clears it.

Discriminate probe failures with describeClaudeProbeFailure: session-limit
and rate-limit hits get their own messages (preserving the upstream reset
text), and genuine auth errors keep the original guidance. Also add the
session/usage-limit markers to the shared rate-limit classifier so the
governor stops treating a cap as a generic error.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@vercel

vercel Bot commented Jun 13, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
ktx-docs-site Ready Ready Preview, Comment Jun 13, 2026 1:26pm

Request Review

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@kevinmessiaen kevinmessiaen self-assigned this Jun 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants