Repository navigation
A rate limit, an empty account or a refused model is not a refused key; error.detail says why and whether a retry can succeed - #734
Conversation
… is said as that, not as a refused key; error.detail says why and whether a retry can succeed _PROVIDER_REFUSAL_RE matched 429, "rate limit" and "quota" the same as 401 and an invalid key, so each read "Your <provider> key was refused". The rule still decides that the turn stops on this connection (_provider_refused, unchanged in effect), and _provider_failure_kind tells the four apart: - refused (401, 403, invalid key, forbidden): "Your <provider> key was refused: ...", unchanged. - rate limit (429, rate_limit): the key was not refused; wait, with the provider's own wait when its line names one. - quota (insufficient_quota and the like, which OpenAI sends as a 429): add credit with the provider. - model (does not have access to model, not allowed to use model, model_not_found): the key was accepted; choose another model or enable this one. error.detail gains reason (provider_key_refused, provider_model_refused, provider_quota_exhausted, provider_rate_limited), retryable (rate limit only) and retry_after_seconds when named, beside base and tool. The code stays turn_failed. The rule now also reads rate_limit; a bare "too many requests" stays off it, since Entra's own throttling says that on a sign-in that moves on. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
@richard-epsilla could you review this when you have a moment? Problem. When the provider turns down an install's own key, a rate limit, an empty account and a model the provider won't serve for that key all read "Your key was refused". People go and check a key that works. A client with automatic retries also has nothing machine-readable to tell "retry later" from "stop". Approach. Whether the turn stops on that connection is unchanged. Only the wording changes, by cause, and What I'd like from you:
|
The problem
When the provider turns down an install's own connection, every answer that matches
_PROVIDER_REFUSAL_REis worded as a refused key: 401, 403, 429, "rate limit" and "quota" alike. Three of those are not the key at all:insufficient_quotaas a 429.Each one sends people to check a key that works. The failed response's error also gives a client with automatic retries nothing machine-readable to tell "retry later" from "stop". It carries
turn_failedplus the base and tool, so the only signal is the message's wording.Reproduced on
main(93994cf):The fix
_provider_refusedstill decides that the turn stops on this connection, with the same effect as before, including the relay exception from #714. The new_provider_failure_kindchanges what the turn says:error.detailaddsreason: provider_key_refused,retryable: falserate_limitreason: provider_rate_limited,retryable: true,retry_after_secondswhen namedinsufficient_quotaand similarreason: provider_quota_exhausted,retryable: falsemodel_not_foundreason: provider_model_refused,retryable: falseturn_failed. The new fields sit indetailbesidebaseandtool(Errors §1, "structured extra context"), so no client that reads the code sees a change.rate_limit. A bare "too many requests" stays off it, because Entra's own throttling answers a 502 with "AADSTS90055: Too many requests." That is a sign-in failure, and it still moves on as before.test_entra_failing_is_not_a_refusal_of_the_connectioncaught this.Verified
Against
main'sapp.py:The one that passes is the check that other failures add nothing.
The tests that already covered this path all pass:
test_turn_failure_message,test_failure_detail,test_entra_connection,test_relay_401_is_not_a_key_refusalandtest_memory_provisioning, 120 tests in total.The full gateway suite on this branch:
The 13 failures are all in
test_database_mcp.py, and the same 13 fail onmainon my machine, which has no database server for those tests.main's CI is green on them.🤖 Generated with Claude Code