Repository navigation
perf(gateway): skip provider catalog rewarm on rate limits - #125906
Conversation
Rate-limit auth-profile failures no longer clear the provider auth cache or
trigger a full catalog rewarm: the failure hook now carries {reason, source}
and the gateway prewarm skips rewarm for rate_limit cooldowns. Session
listing moves to a narrow read-only facade (clone:false, list projection)
so `openclaw sessions` stops importing the full mutation/lifecycle accessor
graph. Device identity loads read-only on CLI start instead of opening the
state DB through the writer/repair lifecycle. CLI backend resolution uses
the lightweight runtime-state registry instead of the loader facade.
Trimmed against upstream: the ACP session-meta batch reader is superseded
by readAcpSessionMetaBatch (openclaw#114659); model metadataSnapshot pinning is
superseded by openclaw#125569; the startup-migration DB-warm change is owned by
open PR openclaw#122005.
Co-Authored-By: Claude Fable 5 <[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 real behavior proof before merge. Reviewed September 5, 2026, 3:51 PM ET / 19:51 UTC. ClawSweeper reviewWhat this changesThe PR passes failure reasons through the internal auth notification hook, skips Gateway catalog rebuilding for rate limits, and adds regression coverage plus a built-Gateway smoke test. Merge readiness⛔ Blocked before merge - 3 items remain This remains a useful, focused repair: current main still invalidates the provider catalog on rate-limit failures, and related merged work does not replace it. No blocking correctness finding was identified; successful runtime evidence for the rewritten implementation remains outstanding. Priority: P2 Review scores
Verification
How this fits togetherAgent failures update credential-profile health and notify the Gateway’s prepared provider-auth catalog. That catalog helps model listing determine credential availability, while separate cooldown logic controls profile selection. flowchart TD
A[Agent request fails] --> B[Record profile health]
B --> C[Notify failure reason]
C --> D{Rate limit?}
D -->|Yes| E[Preserve prepared catalog]
D -->|No| F[Invalidate and schedule recovery]
F --> G[Rebuild provider availability]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +4, Tests +277, Other +1. Total +282 across 8 files. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep reason propagation and filtering at the existing catalog owner; the four added production lines supply the type import and invariant comment without adding another recovery path. Do we have a high-confidence way to reproduce the issue? Yes, source establishes that current main sends rate-limit failures through unconditional catalog invalidation; the supplied CI evidence also records the focused pre-fix failures. This review did not execute a reproduction. Is this the best way to solve the issue? Yes, the existing notification and catalog owner are the appropriate boundaries: suppressing failure recording would damage cooldown behavior, while another cache or timer would duplicate lifecycle policy. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against de2c4b1768d9. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (10 earlier review cycles; latest 8 shown)
|
Integrate current main without replacing contributor ancestry and narrow this PR to the rate-limit rewarm defect. Preserve current session projection and startup lifecycle behavior; defer unrelated CLI and device-store changes. This regression-first commit intentionally fails until reason propagation and subscriber filtering are repaired. Secretless fork CI records that proof. Co-authored-by: Grynn <[email protected]>
|
The final repaired head is Both before-fix failures were captured in secretless CI: 33979786806 demonstrated lost failure reasons, and 33980563586 demonstrated two unwanted invalidations after two rate limits. The final repair passes the existing reason through the internal hook and filters rate limits before touching the prepared snapshot or queued recovery. Independent source review and fresh integration autoreview found no actionable P0–P2 findings. Final-head CI 33985236614 is pending; this is not a claim that its tests have passed yet. |
Forward the existing failure reason through the internal hook without changing cooldown persistence or adding an optional event shape. Both profile and inline-key bookkeeping retain their error handling. This intermediate checkpoint lets CI reach the still-unfixed Gateway rate-limit regression after the producer regression passes. Co-authored-by: Grynn <[email protected]>
Rate-limit cooldowns change profile selection without changing credential presence. Skip invalidation before touching the prepared snapshot or queued repair, while retaining authentication and billing recovery. Refs openclaw#125315. Producer and Gateway regressions failed independently in secretless CI before their respective repairs. Co-authored-by: Grynn <[email protected]>
Merge the main commit containing openclaw#139176 after the fork CI reproduction hit its known cold-runner timing failure. Preserve contributor ancestry and the reviewed rate-limit auth-catalog repair unchanged. Co-authored-by: Grynn <[email protected]>
|
@clawsweeper re-review The current head narrows this PR to the reason-aware rate-limit rewarm repair, integrates current-main lifecycle behavior and the canonical #139176 CI fix, and records separate before-fix producer and Gateway regression failures. The body now describes the final five-file scope and the precise proof limits. Exact-head CI is pending. |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
…ntime Use isolated synthetic profiles, real agent RPCs and HTTP failures, and canonical SQLite reads to cover the producer-to-subscriber composition. Keep the immediate no-invalidation unit regressions and report the runtime smoke's negative observation window explicitly. Register the test with the existing built-runtime prerequisite owner. Refs openclaw#125315.
Declare explicit ownership for the two named test agents and retain the exact runtime-consumer grouping assertion. Use a block-bodied Promise executor for mock-server cleanup without changing cleanup behavior. These fix the first secretless runtime-smoke attempt before actual Gateway failure/recovery proof. Production behavior is unchanged.
|
The repaired-head built-Gateway smoke now has execution proof: CI job passed in 17.819 seconds. Actual merge SHA Four synthetic HTTP 429 requests recorded cooldowns and produced zero catalog rewarms over the bounded five-second observation. A subsequent HTTP 401 recorded its authentication failure and produced one rewarm. The strict unit regressions separately verify immediate invalidation behavior. This is real built-Gateway/mock-provider proof, not authenticated-provider testing or a timing benchmark. The run exposed a planner-test formatting mismatch between local 0.60 and pinned 0.65. Head |
|
Final exact head The real Gateway recorded cooldowns after four HTTP429 requests, with zero rewarms over five seconds; the subsequent HTTP401 recorded an authentication failure and triggered one rewarm. Both persistence facts are true. This fulfills the latest ClawSweeper proof/rank-up request. The observation window is bounded and complements the strict immediate-invalidation regression; this is mock-provider execution, not an authenticated-provider or timing benchmark. The full proof is in the PR body. The broader startup and identity proposals in #125315 remain open follow-ups. |
|
Merged via squash.
|
…125906) Carry profile failure reasons through the internal hook and preserve the prepared provider-auth catalog on rate limits. Authentication and billing failures retain the existing recovery path; cooldown recording and profile selection are unchanged. Cover reason propagation and queued recovery with regressions, plus built-Gateway HTTP429-to-401 proof using synthetic credentials and real SQLite state. CI 33989197791 passed on source head 54c9fd5. Refs openclaw#125315. Its separate CLI and device-identity proposals remain follow-ups. Original diagnosis and repair by @Grynn. Co-authored-by: Grynn <[email protected]> Co-authored-by: Peter Steinberger <[email protected]>
Refs #125315.
What Problem This Solves
Ordinary rate-limit cooldowns invalidated the Gateway's prepared provider-auth snapshot and scheduled another full catalog rebuild. A previous real-Gateway reproduction on this PR measured an 11.3-second rebuild even though a rate limit does not change whether credentials exist.
Why This Change Was Made
Carry the existing failure reason through the internal notification hook and let the Gateway skip rate-limit invalidation at the owner of the prepared snapshot. Both profile and inline-key failure producers retain their persistence and error handling. Authentication and billing failures still trigger recovery; a rate limit cannot cancel a repair already queued or running.
This integrates current main without replacing the contributor's ancestry. The original optional event object and unused source field are removed. Current session projection is retained, while the separate CLI import and device-identity proposals remain follow-ups under #125315.
User Impact
Rate-limited agents avoid redundant provider-catalog work. Cooldown recording, profile selection, credential validation, configuration, plugin SDK contracts, and storage schemas remain unchanged.
Original diagnosis and implementation: @Grynn (Vishal Doshi).
Evidence
0d7d56024f83fd710b9f30a6e888345950f7bcd9, recorded four expected failures because the callback received no reason; 14 existing producer tests passed.bc559c3ba51dbdab85924cf0487f79cb08eb8fe1, reached the Gateway regression and showed two unwanted invalidations after two rate-limit events. The other 198 startup-core tests passed.886aaa689076b7b7c2f7a4d8d0048e89f5855698) through an ancestry-preserving merge.fe6ddac991f4faedfa23836b5b05485be8f61a05passed CI 33985236614.72c8c4f08b38bb9006643acae976ba21f4fa9d29, with PR headf7efc490960002ba1b7da86fd2d65cb166970d72as its second parent. The three repaired production modules and the runtime smoke match that PR head byte-for-byte. Four HTTP rate-limit requests recorded cooldown state and produced zero rewarms during the five-second observation; the subsequent HTTP authentication failure recorded failure state and produced one rewarm.54c9fd565523b7fca8cfd451ba563d5d2428eaderestores the pinned formatter output (+8/-9 whitespace-only), with all non-whitespace bytes identical and the targeted 0.65 format check passing. Production and runtime-smoke source remain byte-identical to the observed run. Exact-head CI 33989197791 passed, including the pinned formatter and Gateway runtime smoke.The new runtime smoke pins the compiled checkout, stages distinct synthetic per-agent profiles, verifies the credential actually used over HTTP, waits for explicit terminal outcomes, reads real SQLite failure state, and records bounded rewarm counters. It complements the unit tests that enforce immediate no-invalidation behavior; its negative log observation is limited to five seconds. The observed run exercises the real built Gateway and SQLite persistence against a local mock HTTP provider; it is not authenticated-provider proof or a performance benchmark.
Historical real-flow proof on original contributor head
8637dad9e5282b188f6cfd666ae696431d73ee5cused the same isolated Gateway process against a local HTTP provider: a 429 recorded its cooldown with zero catalog rewarms, then a 401 caused one rewarm. This is real Gateway/mock-provider evidence, not authenticated-provider proof or a fresh timing measurement of the rewritten head.Final-head runtime proof: job 101368367710 passed in 19.025 seconds. The actual built merge
e4fe993a35e91eb4bee1dcc602f9f49fec3c977bhas parentse8fbf33b32bea82769237675b99e03355ba3a50eand exact PR head54c9fd565523b7fca8cfd451ba563d5d2428eade.{ "head": "e4fe993a35e91eb4bee1dcc602f9f49fec3c977b", "requests": { "rate": 4, "auth": 1 }, "rateCooldownRecorded": true, "authFailureRecorded": true, "rateObservationMs": 5000, "afterRateRewarms": 0, "afterAuthRewarms": 1, "prHead": "54c9fd565523b7fca8cfd451ba563d5d2428eade", "mergeParents": [ "e8fbf33b32bea82769237675b99e03355ba3a50e", "54c9fd565523b7fca8cfd451ba563d5d2428eade" ], "ciRun": 33989197791, "ciJob": 101368367710, "durationMs": 19025 }Latest ClawSweeper disposition: the 19:51 UTC review found no blocking correctness defect and requested successful rewritten-head Gateway output. The linked passing run fulfills that proof and rank-up request. Its five-second negative observation remains explicitly bounded; the complementary focused regression enforces immediate no-invalidation behavior. No rank-up move is silently skipped. The broader CLI and device-identity slices of #125315 remain follow-ups.