Skip to content

[WRONG BRANCH] fix(errors): hop on Anthropic 400 "Third-party apps now draw from your extra usage" - #11

Merged
vadymhimself merged 1 commit into
release/2.65.0-vadymhimself.15from
be-low-r8/third-party-extra-usage-failover
Nov 7, 2026
Merged

vadymhimself merged 1 commit into
release/2.65.0-vadymhimself.15from
be-low-r8/third-party-extra-usage-failover

Conversation

@vadymhimself

Copy link
Copy Markdown
Collaborator

Fork #8 covers "You're out of extra usage" (src/lib/errors.ts:434). Anthropic now also answers 400 "Third-party apps now draw from your extra usage, not your plan limits", which still classifies as invalid_request_error, so comboFailureDecision returns stop (src/combos/failover.ts:786) and the House waterfall never reaches its GPT tier.

Change: one more text.includes in the insufficient_quota branch of classifyError; exact-text asserts in tests/server/error-fidelity.test.ts and tests/codex-integration/combos.test.ts.

Verified: bun test on both files 102 pass / 0 fail; with the src match reverted, the 2 new asserts fail (2 fail); tsc --noEmit clean.

package.json is already 2.65.0-vadymhimself.16, so merging this commit and tagging v2.65.0-vadymhimself.16 on it needs no bump.

Eval added/updated: N/A deterministic (unit test: tests/server/error-fidelity.test.ts, tests/codex-integration/combos.test.ts)

🤖 Generated with Claude Code

…our extra usage" as insufficient_quota so combos hop

Same spent-plan state as "out of extra usage" (#8), newer Anthropic wording. Without it the
400 classifies as invalid_request_error and a combo stops instead of hopping to the next tier.

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

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown

✅ Deterministic PR hygiene checks passed.

@github-actions github-actions Bot added the bug Something isn't working label Nov 7, 2026
@github-actions github-actions Bot changed the title fix(errors): hop on Anthropic 400 "Third-party apps now draw from your extra usage" [WRONG BRANCH] fix(errors): hop on Anthropic 400 "Third-party apps now draw from your extra usage" Nov 7, 2026
@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

⏳ DRAFT

  • wrong target branch (release/2.65.0-vadymhimself.15); retarget to dev.

What to do

  • Retarget this PR to dev — all contributions go to dev.

Its title has been prefixed with [WRONG BRANCH].
Automatic draft conversion failed (token cannot change draft status). Please convert this pull request to a draft manually. The required enforce-target check will keep failing until every issue above is resolved.

@github-actions
github-actions Bot marked this pull request as draft November 7, 2026 19:55
@vadymhimself
vadymhimself marked this pull request as ready for review November 7, 2026 20:30
@vadymhimself
vadymhimself merged commit 79faf06 into release/2.65.0-vadymhimself.15 Nov 7, 2026
29 of 30 checks passed
vadymhimself added a commit that referenced this pull request Nov 14, 2026
)

* fix(pool): rotate Anthropic pool accounts on out-of-extra-usage 400

Anthropic answers an account whose plan and extra usage are spent with
HTTP 400 ("You're out of extra usage", "Third-party apps now draw from
your extra usage"), not 429. Since #8/#11 src/lib/errors.ts classifies
both as insufficient_quota, so a combo hops on them, but the Anthropic
account pool still rotated on status 429 only (adapter-dispatch,
adapter-continuation, and the web-search/image sidecar loops). One spent
pool account therefore failed the request while the other pool accounts
sat idle; on a hosted gateway, which has no combo, the caller got the
error.

Add src/oauth/anthropic-pool-rotation.ts: isPoolRotatableStatus() and
peekAnthropicPoolRotation() decide the trigger ("429" or "quota-400").
A 400 counts only when the existing classifyError() says
insufficient_quota, so no message wording is duplicated, and any other
400 (a malformed request) is passed through untouched. The 400 body is
read with the bounded peek the key-pool 429 path already uses
(readQuotaResetAt, which now also returns the peeked text), and the
returned response replays it.

All three rotation sites use the helper. The sidecar hook moves only the
Anthropic pool on a quota-400; key pools and the generic OAuth roster
still rotate on 429 alone.

rotateAnthropicAccountOn429() takes the trigger. On a quota-400 it always
cools the account (the 400 is quota evidence even if the unified status
header still reads "allowed"), using the same Retry-After, then
rejected-window reset, as a quota 429. With neither, it falls back to 10
minutes, the cooldown the combo layer gives the same insufficient_quota
code, not the 60s rate-limit default that would send the next request
back to the spent account a minute later.

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

* fix(pool): anchor the quota-400 match to Anthropic's envelope and exact phrases

Security review (Mars, RED R1): isQuotaExhaustedBadRequest ran the whole
400 message through classifyError, which matches quota words anywhere in
the text. Anthropic's validation 400s echo client values back (tool ids,
model names, prompt text), so one crafted request such as a tool_use id
"toolu_insufficient_quota" could cool every pool account for 10 minutes.

The 400 now counts only when the body is Anthropic's JSON error envelope
(type "error", error.type "invalid_request_error") and error.message,
after leading whitespace, starts (case-insensitive) with "You're out of
extra usage" (straight or curly apostrophe) or "Third-party apps now draw
from your extra usage". A non-JSON body, another error type, a missing
envelope, or the wording anywhere but the start never rotates.
classifyError is no longer used here; combo classification is unchanged.

R2 (REAL-PAYLOAD-RATCHET): the third-party test payload is now the real
recorded Anthropic 400 (staging gateway log line, 2026-11-11), copied
byte-identical from AgentRadarLabs/agentradar-paperclip
fixtures/external/anthropic-extra-usage-thirdparty-400.txt @ 615ec8db69
into fixtures/external/anthropic/ with a README saying where it came
from. No real "You're out of extra usage" body has been recorded anywhere
(paperclip marks its sample "derived"), so that wording stays a typed
test string.

New must-fail tests (5 fail on the previous commit): a 400 echoing
toolu_insufficient_quota neither rotates nor changes on its way to the
caller; the wording mid-message does not rotate; the right wording in a
wrong envelope (rate_limit_error, api_error, missing type "error",
non-string message, array body) does not rotate; raw non-JSON text does
not rotate.

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

* chore(release): 2.65.0-vadymhimself.22

The fix commits on this branch inherited 2.65.0-vadymhimself.21, which
names an already-published tag, so release-version-line failed.

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

---------

Co-authored-by: Gauge <gauge@agentradar-house.staging.agentradar.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
vadymhimself pushed a commit that referenced this pull request Nov 16, 2026
…ites (lidge-jun#8590)

* devin: opt-in Cognition blocklist rewrite on history data surfaces

The blocklist sanitizer only touched instruction surfaces (tool descriptions, the #2 system prompt); data fields stayed byte-exact, so one quoted trigger phrase anywhere in a long thread history made every later request fail with upstream permission_denied.

New OPENCODEX_DEVIN_SANITIZE_DATA_SURFACES=1 opt-in extends the same rewrites to message text (#3), tool-call arguments (#6.3), image captions (#10.3) and replayed thinking (#11). Identifiers (tool name, tool_call_id) and opaque signature blobs stay byte-exact. Off by default: rewriting literal history changes what the model sees, so refusing stays the default failure.

The permission_denied hint now names the opt-in. Tests pin both modes: data literal by default, rewritten when enabled.

* devin: add Codex CLI boilerplate phrases to Cognition blocklist rewrites

Two more live-isolated triggers in the Codex CLI developer boilerplate: the identity sentence "Codex refers to the open-source agentic coding interface" and the "Don not output ANSI escape codes directly — the CLI renderer applies them" bullet. Both are rewritten meaning-preservingly like the existing entries. Also adds the dump/bisect probe scripts used to isolate the triggers.

* fix(devin): drop stale signatures after thinking sanitization

Keep reasoning signatures only when the serialized thinking is unchanged.
Preserve signature-only replay and default-off sanitization, and add wire,
authentication and continuity regressions with matching adapter docs.

* chore(devin): keep live credential probes out of the runtime PR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant