The failure kept only while the turn runs the route resolution fell back to. That was decided after the agent was built, by rebuilding the agent's URL and query and comparing it with a recorded backup URL; every derivation AIAgent applies to its route (query moved to default_query, escaping, normalization) was one more way for the comparison to be wrong, and the account (api_key) was never compared at all.
Both places that apply overrides before building the agent (the gateway turn's API and one-turn routes, the API server's model_routes and request provider) now snapshot provider, base_url and api_key as resolved and drop the failure when any differs afterwards: plain equality on the turn's own values, before any agent exists. The URL comparison, its helpers and the recorded backup URL are removed; the key guard from the previous commit is widened to the whole route.
Reported-by: greptile-apps[bot]
Reported-by: kvnloo
AIAgent decodes a base_url's query into default_query; re-encoding it to compare spelled an escaped space, slash or hex digit differently from the configured URL, so the backup itself lost the primary's sign-in lead. Both sides now compare as the query-free URL plus the decoded query. A missing or different query is still another route.
Reported-by: gpt-6-astra cold review
18d88aa7d1 compared the backup URL with the agent's URL plus its client default_query, which covers an AIAgent built from the URL. An agent whose base_url carries no query and whose client kwargs record none (a route copied without them) still runs the backup's query-free URL; that now matches too. A known, different api-version stays a different route.
Reported-by: BearHuddleston
AIAgent moves a base_url's query (Azure's ?api-version=) into the client's default_query and keeps the query-free URL on base_url, so the recorded backup URL never matched and a fallback that had not moved lost the primary's sign-in lead. The agent's route URL now carries its default_query back, and two api-versions of one endpoint stay different routes.
Reported-by: greptile-apps[bot]
lead_failed_turn_with_primary_auth skipped the lead whenever the running provider slug equalled the primary's, so a fallback entry on the same provider with other credentials and another endpoint hid the primary's lapsed login. It now skips only when the turn is not on the recorded backup route, which is the primary serving again.
Reported-by: kshitijk4poor
lead_failed_turn_with_primary_auth wrote both _primary_auth_led and the primary_auth_failure descriptor in the same step; the descriptor now serves as the marker. A comment in gateway/run.py ran on past its line into the import's trailing comment.
Reported-by: kshitijk4poor
attach_primary_auth_failure compared only the provider slug, so a route that `/model --once`, a channel override or an API caller moved to a different endpoint of the same provider (a `custom` fallback swapped for another `custom` URL) kept the "switched to the backup" lead and the primary's sign-in card. The failure now records the backup's base_url, and the agent must run that endpoint too, compared with normalize_route_base_url; a named custom route that runs its own endpoint keeps the lead.
Reported-by: kshitijk4poor
no_provider_configured, invalid_provider and missing_base_url are raised as AuthError, so the resolution walker falls back on them, and if the backup then failed the lead told the user to sign in again with a command that cannot fix a configuration. They join the codes that are not a login problem; credential codes still lead.
Reported-by: unsupportedpastels
The lead redacted the primary's error with force=True, but the turn result's descriptor copied the raw text, and _FAILURE_DESCRIPTOR_KEYS forwards it with the turn result. It is now redacted the same way; provider and relogin are unchanged.
Reported-by: BearHuddleston
The failure found while resolving a turn's route was stashed on the shared runner, so another chat resolving on another thread could clear or replace it before the turn read it, and the sign-in hint went missing or named another session's provider. It now travels in a context variable, which each gateway turn's executor copy keeps to itself.
The failure also survived later steps that move the turn onto another provider (`/model --once`, an API caller's provider, a channel override), so a failure of that route told the user to sign in to the primary. attach_primary_auth_failure now drops it unless the agent runs the backup it names.
Reported-by: greptile-apps[bot]
primary_auth_failure_from_exc treated every remaining AuthError as a login a re-login fixes. Anthropic's per-model cooldown carried no code, and missing_external_process_cli passed the filter, so a backup's later failure told the user to sign in again when the login still worked or the CLI was not installed. The cooldown now carries code model_rate_limited, and both codes join the ones that are not a login problem.
Reported-by: greptile-apps[bot]
Darling, "you're out of credits" is not the whole story when the real
problem is that your Claude login expired an hour ago. Resolution-time
fallback quietly swapped the dead Anthropic login for the backup and then
let the backup's billing error do all the talking.
- resolve_runtime_with_fallback stamps a PrimaryAuthFailure (provider,
error, exact re-login command) on the fallback runtime when the primary's
AuthError is one a re-login fixes (not quota/entitlement/retryable).
- The gateway (messaging + launch-policy routes), API server and oneshot
carry it onto the agent; the gateway clears it per turn so a cached
agent never keeps a login failure that has since resolved.
- run_conversation leads any failed turn on the backup with "<primary>
needs you to sign in again: run `hermes auth add anthropic`" and still
names the backup's problem ("the backup is out of credits"), with the
backup's own copy underneath.
Fixes#147212