Skip to content

fix(combos): hop past Anthropic's extra-usage refusal - #8588

Merged
lidge-jun merged 5 commits into
lidge-jun:devfrom
AgentRadarLabs:fix/anthropic-extra-usage-hop
Nov 14, 2026
Merged

lidge-jun merged 5 commits into
lidge-jun:devfrom
AgentRadarLabs:fix/anthropic-extra-usage-hop

Conversation

@vadymhimself

@vadymhimself vadymhimself commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Verification

All commands used the pinned Bun 1.4.4 with an isolated HOME.

  • bun test tests/routing/router-anthropic-billing-failover.test.ts: 3 pass, 0 fail. With the src/ change reverted, the new test fails (2 pass, 1 fail).
  • bun scripts/test.ts --changed=upstream/dev: 43601 pass, 6 fail. All six fail identically without this change:
    • codex-composed-acceptance ×2 (fails the same way on the base)
    • connected-client runtime probe scope
    • link-ocx-child-e2e ×2
    • retained sync and serve-options
  • bun run typecheck, bun run structure:check and bun run privacy:scan all pass.
  • I updated structure/runtime.md to match.

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed.
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults.

Review readiness checklist

This PR stays in draft until every box below is ticked. Tick all four boxes once the requirements are met:

  • Required local validation passed; commands, results, and any full-suite exception are documented.

  • I pushed my PR to a recent dev commit (at most 10 behind; a maintainer may still ask for the exact tip before merge).

  • I resolved all correct Codex and CodeRabbit findings.

  • My PR is ready for review.

Summary by CodeRabbit

  • Bug Fixes
    • Combo routing now moves to the next option for recognized Anthropic extra-usage refusals in supported plain-text and structured error responses. The cooldown applies only to the affected target. Other error types, quoted messages, and unsupported coded variants remain terminal.
  • Documentation
    • Runtime guidance now describes the supported refusal messages, the error details required for failover, target-specific cooldown behavior, and cases that remain terminal.

Latest dev merge validation — 2026-11-14

Merged upstream/dev at 873ec9b3b8 with a merge commit (no rebase). Pinned Bun 1.4.4, isolated HOME/OPENCODEX_HOME. --changed=upstream/dev: 46,498, 6 known base/environment failures (the same 4 listed above plus WP13 composed acceptance ×2). Affected billing/failover suites: 189 pass, 0 fail. Typecheck, structure:check, and privacy:scan pass. No new runtime changes. Full changed-mode run is not green; the listed exceptions remain disclosed.

The 4 common exceptions are retained sync/serve-options, connected-client runtime probe, and compiled Child lifecycle ×2 (cc exits 69).

Integration coordination

andrew05060414 independently checked the overlap, agreed that target-scoped cooldown is the safer contract, and closed #8649 in favor of this PR: #8649 (comment). Credit to them for that comparison and regression check. No code was taken from their branch. The shared credit-balance predicate remains unchanged. This resolves the contributor coordination question; maintainer approval is still required.

🤖 Generated with Claude Code

Anthropic refuses an OAuth turn that bills against an empty extra-usage
balance with HTTP 400 invalid_request_error ("You're out of extra usage"
or "Third-party apps now draw from your extra usage, not your plan
limits"). comboFailureDecision treated it as a terminal invalid request,
so a combo ended the turn instead of reaching its next tier.

Recognize the exact wording under the credit-balance evidence bar
(invalid_request_error envelope, or exact prose with that structured code)
and grant a target-scoped hop. Quoted, coded and other-typed variants stay
terminal.

Carried from the vadymhimself fork (e987656, 79faf06).

Co-Authored-By: Claude Code <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

✅ Deterministic PR hygiene checks passed.

@github-actions github-actions Bot added bug Something isn't working review-ready labels Nov 12, 2026
@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

✅ READY

  • all PR quality gates passed; the review readiness checklist is complete.

Review readiness checklist

  • ✅ Required local validation passed; commands, results, and any full-suite exception are documented.
  • ✅ I pushed my PR to a recent dev commit (at most 10 behind; a maintainer may still ask for the exact tip before merge).
  • ✅ I resolved all correct Codex and CodeRabbit findings.
  • ✅ My PR is ready for review.

✅ 4/4 boxes ticked.

This pull request has been marked Ready for Review.
The review-ready label marks this PR as ready; review automation runs independently.
Maintainers notified: @lidge-jun @Ingwannu

Hygiene

✅ Deterministic PR hygiene checks passed.

@coderabbitai

coderabbitai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The change adds recognition for specific Anthropic extra-usage refusals and uses matching HTTP 400 responses to trigger combo failover. Tests cover accepted and terminal response variants. Runtime documentation describes the refusal patterns and handling.

Changes: Anthropic extra-usage failover

Layer / File(s) Summary
Refusal classification
src/providers/anthropic-billing-refusal.ts
The classifier recognizes exact extra-usage refusal messages and checks the HTTP status, code, and response format. A shared helper normalizes provider-prefixed messages.
Combo failover and validation
src/combos/failover.ts, tests/routing/router-anthropic-billing-failover.test.ts, structure/runtime.md
Combo failure handling hops when the classifier matches. Tests cover accepted and terminal variants. Runtime documentation describes the refusal patterns and handling.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Possibly related issues

  • lidge-jun/opencodex#7965 — The change treats a matching Anthropic extra-usage refusal as a target-scoped hop, but does not add the requested combo_exhausted diagnostic.
  • lidge-jun/opencodex#8288 — The change recognizes the reported Anthropic OAuth refusal wording, but does not address the issue’s instruction-placement cause.
Merge Risk: Minimal · up to e1549

This change lets a combo move to its next tier when Anthropic refuses a request because the extra-usage balance is empty. Quoted, coded or other-typed variants still stop the combo as before. No concrete risk was found that should block merging.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "fix(combos): hop past Anthropic's extra-usage refusal" names the main change. The changeset adds isAnthropicExtraUsageFailure, wires it into decideComboFailure in src/combos/failover.ts so …
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Full details: Title check

Explanation

The title "fix(combos): hop past Anthropic's extra-usage refusal" names the main change. The changeset adds isAnthropicExtraUsageFailure, wires it into decideComboFailure in src/combos/failover.ts so a matching status returns "hop", and adds tests and docs for the Anthropic extra-usage refusal. The title is short, single-sentence, and specific, so it passes.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 50b8716 and e1549c4.

Files selected for processing: 1

  • src/combos/failover.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.

@github-actions
github-actions Bot marked this pull request as draft November 13, 2026 01:01
…usage-hop

Co-Authored-By: Claude Code <noreply@anthropic.com>

@Ingwannu Ingwannu left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exact-head source follow-up for c0c560a8d62e219a285d397eb2aebf181d11c637.

I reviewed the complete four-file diff. The new helper requires the exact bounded extra-usage wording and invalid_request_error carrier; its Combo check runs before generic invalid-request stop, and the regression asserts a target-scoped hop while preserving coded/other-typed/quoted negatives. Existing current-head fork CI has now been allowed.

Please coordinate with #8649, which independently extends the shared billing predicate and explicitly asserts provider-scoped cooldown for overlapping wording. The two implementations have materially different account/cooldown effects and phrase coverage. Choose and document that contract with the owner before merging the overlap; no duplicate closure or contributor-branch takeover is needed. CI permission here is separate from that integration decision and from approval. No local provider/account call or scan was made.

Co-Authored-By: Claude Code <noreply@anthropic.com>
@vadymhimself

Copy link
Copy Markdown
Contributor Author

Thanks for flagging #8649. @andrew05060414, the overlap is real, but the contracts differ. My proposed contract here remains a target-scoped hop, with the shared credit-balance predicate unchanged. Both PRs accept the exact short/long “out of extra usage” sentence and either apostrophe; this PR additionally accepts the exact “Third-party apps now draw from your extra usage, not your plan limits” sentence. Here the carrier must be invalid_request_error, with no nested error.code; quoted, decorated, other-typed and coded variants remain terminal.

Scope matters beyond the combo: widening isAnthropicBillingRefusal also reaches rotateAnthropicBillingKeyOnResponse and the key-pool credit-balance cooldown, while isAnthropicBillingFailure controls provider-scoped combo cooldown. This PR deliberately does not authorize those broader effects from extra-usage wording alone. The third-party message can depend on the target/request, so it is not sufficient evidence to cool every target on that provider.

I recommend retaining the separate predicate and target-scoped contract for both phrases. Please confirm the intended owner contract before either overlapping implementation is merged; this comment is a proposal, not a claim of agreement. Happy to incorporate your coverage with attribution once scope is settled. I will not close or modify your PR. @Ingwannu, integration decision is explicitly pending; the green checks are not being treated as approval.

@github-actions
github-actions Bot marked this pull request as draft November 13, 2026 16:56
@github-actions
github-actions Bot marked this pull request as ready for review November 13, 2026 16:57
andrew05060414 added a commit to andrew05060414/opencodex that referenced this pull request Nov 13, 2026
…usage hop

lidge-jun#8649 was closed in favour of lidge-jun#8588, which keeps the evidence in its own narrow helper, covers the third-party-apps wording too, and keeps the cooldown target-scoped.
andrew05060414 added a commit to andrew05060414/opencodex that referenced this pull request Nov 13, 2026
Co-Authored-By: Claude Code <noreply@anthropic.com>
@github-actions
github-actions Bot marked this pull request as draft November 14, 2026 00:56
@vadymhimself

Copy link
Copy Markdown
Contributor Author

Coordination update for @Ingwannu: @andrew05060414 independently checked the overlapping regression against this PR, agreed with target-scoped cooldown, and closed #8649 in favor of #8588: #8649 (comment). Thanks for the comparison and explicit scope decision. No contributor-branch takeover or code import was needed; their verification is credited in the description. Maintainer approval is still pending. This head only merges newer dev; the behavior and negative controls are unchanged.

@github-actions
github-actions Bot marked this pull request as ready for review November 14, 2026 00:57
@vadymhimself

Copy link
Copy Markdown
Contributor Author

CI note on head 2b2c908e7f: the only test changed failure is tests/clients/link-relay-bound-transport.test.ts › "connection-bound link relay > a silent actual peer expires only the credential-free auth deadline without touching the body" (46,528 pass, 1 fail). The PR does not touch link or relay code; that file is reached only through the import graph of src/combos/failover.ts. The same file passes 3/3 locally on this head (17 pass, 0 fail each, pinned Bun 1.4.4, isolated HOME). Reruns need admin rights, so could a maintainer re-run the failed job?

@lidge-jun

Copy link
Copy Markdown
Owner

Maintainer integration into dev (MAINTAINERS.md dev path), recorded by lidge-jun.

  • Head: 2b2c908e7f40f0ccd501361c31aa4617afdb6a1e
  • Scope reviewed: exact Anthropic OAuth extra-usage refusal (HTTP 400, invalid_request_error envelope) grants a target-scoped combo hop; quoted/coded/other-typed variants stay terminal; regression test added.
  • Exact-head CI: Cross-platform CI run 43537420170. The first attempt failed one unrelated test in test changed (connection-bound link relay > a silent actual peer expires only the credential-free auth deadline, outside this diff's code paths); the failed job was rerun once and passed. Catalog async contracts and PR gates pass.
  • Merge gate: scripts/ci/assert-mergeable-review.sh --maintainer-integration OK at this head.

Thanks @vadymhimself.

@lidge-jun
lidge-jun merged commit d842c13 into lidge-jun:dev Nov 14, 2026
53 of 55 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working review-ready

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants