Skip to content

fix(executors): classify Claude plan limit errors as quota - #286

Merged
datacas merged 1 commit into
mainfrom
task-281
Oct 20, 2026
Merged

datacas merged 1 commit into
mainfrom
task-281

Conversation

@datacas

@datacas datacas commented Oct 20, 2026 •

Copy link
Copy Markdown
Owner

Closes #281 — #281

Diagnosis

Claude’s account session-limit response was recorded as executor_error, which prevented the production fallback from recognizing an exhausted quota. The #243 review attempt on PR #278 reported “You've hit your session limit · resets 2:50pm” and stopped without rerouting. Before the fix, python3 -m unittest discover -s tests reproduced the classifier miss: the new session, weekly, Opus, and Sonnet cases all returned no classification (four errors).

The work item’s cause was confirmed. ClaudeAdapter.quota_markers and the shared error-token classifier lacked the specific limit wording. The invariant is that a reported exhausted usage window maps to quota, allowing the existing production fallback to reroute once; calibration runs continue to stop without rerouting.

A widened search covered related items and merged work: #172/#173 and PRs #195/#205 establish the existing classification and reroute behavior; #276 concerns background verification and #280 concerns temporary-file publication, with neither sharing this cause. No other open item is addressed.

The fix recognizes Claude’s exact session, weekly, Opus, and Sonnet exhaustion messages in both classifiers. Tests also ensure incidental limit mentions and the “used 85%” warning do not become quota failures.

Work units

Unit Behaviour Files Tests Verification Rollback
WU-1 Classify Claude plan-limit exhaustion as quota scripts/executors.py, docs/telemetry.md tests/test_executors.py, tests/test_dispatch_failures.py python3 scripts/validate-package.py; python3 -m unittest discover -s tests Independent

Verification (agent-reported)

  • python3 scripts/validate-package.py — passed.
  • python3 -m unittest discover -s tests — passed; 1,613 tests.
  • git diff --check — passed.

The local verification used Python and Git on Linux, matching the Linux CI environment. Windows and installer matrix checks remain for the pushed head.

Implementation run: profile cheap_coder, requested model openai/gpt-6-luna, resolved model ?, effort high.

@datacas

datacas commented Oct 20, 2026

Copy link
Copy Markdown
Owner Author

[CCR-20261020-001] · reviewer · anthropic/claude-sonnet-5-5→? · high · schema:2

Initial review — PR #286 (work item #281)

Status: REVIEW_PASSED_AWAITING_CI — head c82fe78c931d6a7183c5c22d6f3cb89f095d7df7 fully reviewed, no open finding blocks approval. This is not an approval: the required checks of this head are still running, and the CI gate decides.

Scope

Accumulated diff origin/main...HEAD (106 lines, merge base 2c25e824): scripts/executors.py, docs/telemetry.md, tests/test_executors.py, tests/test_dispatch_failures.py. Conventions applied: AGENTS.md (routing only; nothing review-specific). No .code-cycle.yml security rule exists, so the default triage applied.

Findings

None. Observations:

  • _error_class and ClaudeAdapter.quota_markers both gain the session, weekly, Opus, and Sonnet wordings. Matching is lowercase substring, so the markers are narrow: "A test mentions a session limit" and "You've used 85% of your session limit" stay unclassified / executor_error, and the tests assert that.
  • The new dispatch test traverses ClaudeAdapter.dispatch end to end: failure_code == quota, missing_capability == operating_quota, learned_availability == QUOTA_EXHAUSTED. This is the path the production fallback reads.
  • docs/telemetry.md matches the code.
  • Markers use a straight apostrophe, as quoted in the PR. If a Claude CLI version emitted U+2019, it would not match; I have no evidence it does (residual risk below).

Security triage

Not a sensitive change: the security audit was skipped after triage. The rule did not fire (no rule is configured; defaults checked against the changed paths and the absent labels) and my own reading found no authentication, authorization, input, secret, dependency, or deployment surface. The change only widens an error-message classifier.

Verification executed (this clone, sandboxed)

  • python3 scripts/validate-package.py — exit 0, VALID: 16 skills ....
  • python3 -m unittest discover -s tests — exit 1: 1613 tests, 1 failure, 62 errors. Both groups come from the sandbox, not from this diff:
    • 62 errors, all in test_validate_package: shutil.copytree of the checkout fails with [Errno 13] Permission denied on sandbox-masked dotfiles (.bashrc, .claude/*, ...). Unverified here.
    • 1 failure, test_executors.ReadOnlyVerificationTests.test_scratch_never_uses_a_temp_parent_inside_the_checkout ("no temporary directory outside the dispatch checkout"): the checkout and every candidate temp dir sit under /tmp in this sandbox. The diff does not touch scratch-directory logic. Not confirmed on base (read-only stage cannot check out base).
  • test_dispatch_failures.py alone: 28 tests OK, including the new test_claude_session_limit_dispatch_is_a_quota_failure.
  • test_executors.py alone: 185 run, only the environmental failure above; the new test_claude_usage_limit_wordings_are_narrowly_recognised passes.
  • python3 -m unittest (third configured command) was not run separately: it duplicates the discovery run and cannot import the flat test modules without -s tests.

Unverified

The 62 test_validate_package cases and the scratch-directory test could not be exercised in this sandbox; CI on the Linux and Windows runners covers them.

CI (policy: parallel, read once, not waited on)

All five checks of the head are IN_PROGRESS (workflow "Validate package"): Skills, manifests, and Bash installer, Windows test shard (windows-1), (windows-2), (windows-3), (windows-4). None passed, failed, or skipped yet.

Residual risks

  • A Claude CLI wording not in the four recognised messages still lands in executor_error; the narrow markers are intentional.
  • U+2019 apostrophe variant of the messages is not recognised.
  • The environmental test results above stay unverified until CI reports.

Verdict

No blocking findings. REVIEW_PASSED_AWAITING_CI for c82fe78c931d6a7183c5c22d6f3cb89f095d7df7.

ORCHESTRATION_RESULT (JSON)

ORCHESTRATION_RESULT
{
"skill": "cc-initial-review",
"status": "REVIEW_PASSED_AWAITING_CI",
"issue_provider": "github",
"issue_id": "281",
"code_host": "github",
"change_request_id": "286",
"change_request_url": "#286",
"pr_number": 286,
"issue_number": 281,
"comment_url": null,
"head_sha": "c82fe78c931d6a7183c5c22d6f3cb89f095d7df7",
"reviewed_head_sha": "c82fe78c931d6a7183c5c22d6f3cb89f095d7df7",
"review_run_id": "CCR-20261020-001",
"reviewer": {
"profile": "reviewer",
"provider": "anthropic",
"model_requested": "claude-sonnet-5-5",
"model_resolved": null,
"effort": "high"
},
"findings": [],
"blocking_findings": [],
"checks": {"head_sha": "c82fe78c931d6a7183c5c22d6f3cb89f095d7df7", "passed": 0, "failed": 0, "pending": 5},
"blocking": false
}
END_ORCHESTRATION_RESULT

@datacas
datacas merged commit bbd3149 into main Oct 20, 2026
6 checks passed
@datacas
datacas deleted the task-281 branch October 20, 2026 08:49
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.

Claude "session limit" is not recognised as an exhausted window, so the fallback reroute never runs

1 participant