Repository navigation
fix(auth): limit inline key cooldowns to credential failures - #119147
Conversation
|
Codex review: needs maintainer review before merge. Reviewed August 5, 2026, 7:38 AM ET / 11:38 UTC. ClawSweeper reviewWhat this changesThis PR prevents transient provider failures from persisting a provider-wide cooldown for configured inline API keys, while retaining cooldowns for authentication and billing failures. Regression provenancePossible regression — probable (reproduction; reviewed change). No predecessor PR is attributed. Merge readinessNo blocking findings: the PR fixes the provider-wide inline-key state leak at its producer while retaining credential-failure cooldowns and stored-profile timeout handling. The new disposable-VM Gateway A/B evidence satisfies the prior real-behavior-proof request; refresh the exact head because the branch is behind main. Priority: P1 Review scores
Verification
How this fits togetherThe embedded agent runner classifies provider failures and records auth health before later sessions select a credential. Inline API keys have no profile, so their provider-scoped state is read by model resolution and availability checks that can otherwise block every later session. flowchart LR
A[Provider failure] --> B[Failure classification]
B --> C[Failover controller]
C --> D[Inline key state writer]
D --> E[Auth-state store]
E --> F[Later session resolution]
F --> G[Provider request]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +3, Tests +16. Total +19 across 2 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Land the narrow producer-side reason gate after refreshing the exact merge head; retain the existing resolver and stored-profile cooldown policy. Do we have a high-confidence way to reproduce the issue? Yes: current source shows a provider-started timeout reaching a provider-wide inline-key writer, and the supplied disposable-VM Gateway A/B run reports the before-fix block and after-fix recovery on the PR head. Is this the best way to solve the issue? Yes: gating the producer prevents invalid shared state before it reaches every resolver, unlike a resolver-side exception, while preserving established billing/auth cooldowns and stored-profile timeout accounting. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 80da61668eb6. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
|
Independent disposable-VM A/B reproduction completed on 2026-08-04. Baseline artifact:
The baseline wire recorded a successful forced tool call followed by the injected HTTP 503 sequence. Diagnostics then recorded Fixed artifact:
The fixed build still reached the mock provider and observed the injected HTTP 503, but it did not persist an inline-key cooldown. Wire records were present for every formerly blocked scenario. Method: two sequential disposable Proxmox VMs, one fresh VM per artifact, fresh install from each exact build tarball, and the B3 fault-injecting OpenAI-compatible mock-provider lane. |
|
Merged via squash.
|
…w#119147) Co-authored-by: VACInc <[email protected]>
Summary
High Level TLDR
A transient provider timeout could disable a configured inline API key for every later session, even though inline-key cooldowns are intended only for credential auth and billing failures. Restrict the inline-key cooldown producer to those credential failures so unrelated sessions remain usable after transient provider faults.
This is deliberately scoped to inline keys. Stored auth profiles keep their existing timeout and failover accounting.
Root Cause
Commit
196d81195bfadded provider-scoped cooldown persistence for inline API keys. Its controller and resolver describe that state as an auth/billing cooldown, butmarkInlineProviderApiKeyFailureaccepted the fullAuthProfileFailureReasonunion.In the failing artifact, a provider-started status-only HTTP 503 followed the stock path below:
timeout.inline-api-key:qa-mockwith a cooldown.Inline API key ... temporarily disabled after a provider auth/billing failure.The captured no-auto-retry and mutation/compaction scenarios therefore had no provider wire records and never planned or executed their mutation tools. A pre-regression baseline produced each expected mutation file exactly once and completed manual compaction.
Stock counterfactual: stock OpenClaw on the affected code reaches the same failure with an ordinary configured inline provider API key when a provider-started 503 precedes another session. The Nightly wrapper makes that request ordering deterministic but is not in the classifier, cooldown producer, or resolver path.
openclaw update, update finalization, and doctor are not involved and do not own this per-run provider state.Verification
node scripts/run-vitest.mjs src/agents/auth-profiles/usage.test.ts -t 'does not cool an inline key after a provider timeout'Test Files 2 passed (2)Tests 2 passed | 196 skipped (198)node scripts/run-vitest.mjs src/agents/embedded-agent-runner/run.incomplete-turn.test.ts -t 'continues from settled side-effecting tools after an empty stop without replaying them'node scripts/run-vitest.mjs src/gateway/server.sessions.compaction.test.ts -t 'sessions.compact without maxLines runs embedded manual compaction for checkpoint-capable flows'Test Files 1 passed (1)Tests 1 passed | 23 skipped (24)oxfmt --check src/agents/auth-profiles/usage.ts src/agents/auth-profiles/usage.test.tsAll matched files use the correct format.git diff --check origin/main...HEAD.agents/skills/autoreview/scripts/autoreview --mode localautoreview clean: no accepted/actionable findings reportedoverall: patch is correct (0.99)The focused tests used the existing trusted normal-checkout dependencies after remote proof backends failed preflight before source execution: Testbox was not authenticated, Proxmox had no template ID, and AWS had no configured broker.
Real behavior proof
Behavior fixed: a transient provider timeout no longer writes or locks inline-key auth state; auth, permanent-auth, and billing failures continue to use the accepted provider-scoped cooldown.
Closest feasible environment: the captured packaged Gateway run supplied the before behavior, and the focused regression invoked the production cooldown owner with the same
timeoutreason after the patch.Exact after-patch result:
The regression also asserts that
usageStatsremains absent and the locked auth-store updater is never called, proving the transient reason is stopped at the authoritative producer boundary.Production delta is
+4/-1; tests are+16/-0. No retry, replay, compaction, provider classifier, config, schema, or resolver behavior was changed.What was not tested