Repository navigation
fix(models): unblock requests after saving a replacement API key - #169528
Conversation
Co-authored-by: Masato Hoshino <[email protected]>
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
|
Codex review: needs maintainer review before merge. What this changesSaving a replacement API key clears that profile’s old failure state so requests can try the new key immediately. Example: The rotation:manual profile receives HTTP 429 with key A, then an operator saves key B in Models.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Partial Merge readiness✅ Ready for maintainer review Keep open: this maintainer-authored PR repairs a current credential-replacement bug at the existing writer, with convincing production-path evidence and no actionable findings. Priority: P0 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherModels and CLI API-key saves share a credential writer that persists credentials and profile health through the existing SQLite owner and publishes updated runtime state. flowchart TD
A[Models settings] --> C[Shared API key saver]
B[Models auth CLI] --> C
C --> D[Locked profile updater]
D --> E[SQLite credentials and health]
E --> F[Runtime auth selection]
F --> G[Provider request]
Technical reviewBest possible solution: Make Models’ existing Set API key action restore requests immediately by clearing only the replaced profile’s obsolete failure state in the credential transaction. Do we have a high-confidence way to reproduce the issue? Yes: current-main source retains cooldown state during manual key replacement, and the supplied before/after Gateway scenario demonstrates the resulting local rejection; this review executed no target code. Is this the best way to solve the issue? The repair belongs in the shared credential writer and correctly reuses the existing scoped-reset contract without adding another refresh mechanism. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 52200cffda28. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +6, Tests +19, Docs +4. Total +29 across 5 files. Added test files: 0. View PR surface stats
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed October 11, 2026, 10:11 PM ET / October 12, 2026, 02:11 UTC. |
|
Maintainer override The only failing CI job is The identical failure is proven on clean main After the initial fail-fast cancellation, the failed/cancelled jobs were rerun once. All applicable jobs have now completed; only this known main failure and its aggregate remain red. The exact head |
|
Merged as 2b9aa2e. Models and the shared CLI API-key save now clear only the replaced profile’s stale failure state. The real Models → Set API key flow reproduced zero provider calls after rotation on main and a successful key-B request with this fix; all 152 focused tests passed. Exact-head ClawSweeper was ready. Required jobs completed on CI attempt 2; the sole unrelated wrapper-inventory failure used the documented maintainer override. Thank you @masatohoshino for the original fix and @blance2599 for the report. The separate stored-versus-config credential-precedence report remains open. |
…nclaw#169528) Related: openclaw#151354. Carries forward the saved-profile repair from openclaw#160452, which conflicts with current main. ## What Problem This Solves Fixes: after a provider key hits a rate limit, saving a replacement in Settings → Models reports success but the next request is still blocked by the old key's cooldown. ## User Impact User impact: operators can use a replacement API key immediately without restarting the Gateway or waiting for the old key's cooldown. Other accounts, profile order, and usage history stay unchanged. ## Why This Change Was Made Clear only the replaced profile's failure state in the same locked credential write. Models and `models auth paste-api-key` already share this writer; generic writes remain health-preserving unless explicitly asked to reset. Why it was this way: openclaw#124014 deliberately restricted failure-state resets to successful credential replacement rather than clearing every account before login; openclaw#144420 later shared manual key editing through the generic writer without opting into that reset. This applies the existing scoped-reset contract to manual keys while keeping its sibling-account and usage-history protections. No overlap with Pash/Sarah changes. ## Evidence Built isolated Gateways with a loopback OpenAI-compatible stub and dummy keys. Both runs use the actual Models page's **Set API key** action, then the already-connected Gateway transport for the next agent request: | Step | Current main (`b372edb6424e`) | This change (`6dfd10508f8a`) | | --- | --- | --- | | Save key A; request returns HTTP 429 | Rate-limit failure and persisted cooldown | Same | | Save key B in Models | “Secret saved.” | “Secret saved.” | | Immediately request again | `Auth profile "rotation:manual" is temporarily unavailable`; zero provider calls | Stub receives key B and replies “Key B works immediately after rotation.” | The screenshots show the saved-key state. The request results above come from Gateway responses and the stub's recorded requests, not from an inferred screenshot result. | Before | After | | --- | --- | |  |  | - Extended the existing configured/explicit/ordered key-replacement regression: all three cases fail on main because the old cooldown and failure count survive; all pass with the fix. It also preserves a sibling's failure state and the replaced profile's `lastUsed`. - Focused command, locked SQLite writer, and Gateway auth suites: **152 tests passed across four files**. Formatting and `git diff --check` passed. - Final bounded Codex review found no actionable defects. Scope: saved API-key replacement only. The second issue report about stale stored credentials taking precedence over a directly edited config key remains separate; this does not change credential precedence, doctor migration, or logging. Merge danger: two-way door for future saves; reverting restores the old save behavior, but cannot reconstruct cooldown counters already cleared. Blast radius is the one saved API-key profile explicitly replaced through Models or the shared CLI writer. No schema, permission, storage-location, or credential-disclosure changes. Co-authored-by: Masato Hoshino <[email protected]> Co-authored-by: Ayaan Zaidi <[email protected]>
Related: #151354. Carries forward the saved-profile repair from #160452, which conflicts with current main.
What Problem This Solves
Fixes: after a provider key hits a rate limit, saving a replacement in Settings → Models reports success but the next request is still blocked by the old key's cooldown.
User Impact
User impact: operators can use a replacement API key immediately without restarting the Gateway or waiting for the old key's cooldown. Other accounts, profile order, and usage history stay unchanged.
Why This Change Was Made
Clear only the replaced profile's failure state in the same locked credential write. Models and
models auth paste-api-keyalready share this writer; generic writes remain health-preserving unless explicitly asked to reset.Why it was this way: #124014 deliberately restricted failure-state resets to successful credential replacement rather than clearing every account before login; #144420 later shared manual key editing through the generic writer without opting into that reset. This applies the existing scoped-reset contract to manual keys while keeping its sibling-account and usage-history protections.
Evidence
Built isolated Gateways with a loopback OpenAI-compatible stub and dummy keys. Both runs use the actual Models page's Set API key action, then the already-connected Gateway transport for the next agent request:
cbba7e2e2ef4)6dfd10508f8a)Auth profile "rotation:manual" is temporarily unavailable; zero provider callsThe screenshots show the saved-key state. The request results above come from Gateway responses and the stub's recorded requests, not from an inferred screenshot result.
lastUsed.git diff --checkpassed.Scope: saved API-key replacement only. The second issue report about stale stored credentials taking precedence over a directly edited config key remains separate; this does not change credential precedence, doctor migration, or logging.
Merge danger: two-way door for future saves; reverting restores the old save behavior, but cannot reconstruct cooldown counters already cleared. Blast radius is the one saved API-key profile explicitly replaced through Models or the shared CLI writer. No schema, permission, storage-location, or credential-disclosure changes.