fix(anthropic): move oversized OAuth system prompt to user prefix - #13609
Closed
0xyg3n wants to merge 1 commit into
Closed
fix(anthropic): move oversized OAuth system prompt to user prefix#136090xyg3n wants to merge 1 commit into
0xyg3n wants to merge 1 commit into
Conversation
OAuth subscription requests (Claude Code route) fail with 400 'You're out of extra usage. Add more at claude.ai/settings/usage' when the system field contains large custom content beyond the CC identity block. The same payload succeeds with a pay-per-token API key, so the check is subscription-route specific and orthogonal to quota. Fix: keep only the CC identity block in system and fold any extra system blocks into a [CONTEXT]...[/CONTEXT] user-message prefix followed by an assistant 'Understood.' acknowledgement. Content is preserved verbatim; only the transport slot changes. Tested on 0.10.0 (commit b2111a2) with Opus 4.7 OAuth and a SOUL-style ~3k-token system prompt: 400 -> 200 with response latency unchanged.
0xyg3n
force-pushed
the
fix/oauth-system-prompt-overflow
branch
from
April 21, 2026 16:37
7d89325 to
cefb31b
Compare
Contributor
Author
|
Closing to re-open from a clean branch after commit metadata fix. Replacement PR incoming. |
Collaborator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
OAuth / Claude Code subscription requests via
anthropic_messagesfail with a 400 when the system field contains custom content beyond the CC identity block:The error wording points at quota, but the account actually has usage available — the same payload sent directly with a pay-per-token API key returns 200. The check is specific to the OAuth / subscription route and is triggered by the size/content of
systemonce it goes beyond the basic CC identity string.This breaks any downstream that ships a non-trivial system prompt (custom agents, SOUL-style personas, extended tool guides) while using a Claude Code subscription token.
Fix
Keep only the CC identity block in
systemand fold any additional system blocks into a[CONTEXT]...[/CONTEXT]user-message prefix followed by an assistantUnderstood.acknowledgement. Content is preserved verbatim — only the transport slot changes.The change is inside the existing
if is_oauth:branch inbuild_anthropic_kwargs, so it only affects OAuth code paths. Non-OAuth requests (x-api-key, Bedrock, third-party Anthropic-compat endpoints) are untouched.Test
Reproduced and verified against the Anthropic API on the latest main (
b2111a2b):400 invalid_request_errorwith the quota text.system+ rest in[CONTEXT]user prefix →200, response text identical, latency unchanged.Integration tested in a production Hermes 0.10.0 deployment running Opus 4.7 via OAuth with a ~3k-token SOUL-style system prompt: 400 errors cleared, message flow back to normal (4 api_calls / 36s on a cold session with tools).
No changes to non-OAuth paths. No behavioural change expected for users with
systemcontaining only the CC identity block.