Repository navigation
perf(models): bound background catalog renewal to ten minutes per provider - #197124
zeroaltitude wants to merge 14 commits into
Conversation
…vider Provider cache deadlines are often 60s, and every catalog read can start background renewal with one worker task per expired provider. On a Gateway with five agents and heartbeat-paced reads, each agent's catalog worker was renewing continuously (about one full core and 2.5 to 3.4 GiB RSS on the live deployment). Record each provider's renewal deadline as the later of its cache deadline and ten minutes after publication, so background renewal runs at most every ten minutes per provider. Explicit refresh requests are unchanged. Co-Authored-By: Claude Fable 5.1 <[email protected]>
…floor # Conflicts: # src/agents/prepared-model-runtime.native-picker-failures.test.ts # src/agents/prepared-model-runtime.test-harness.ts
…floor # Conflicts: # src/agents/prepared-model-runtime.catalog-access.ts
…floor # Conflicts: # src/agents/prepared-model-runtime.test-harness.ts
…floor # Conflicts: # src/agents/prepared-model-runtime.native-picker-failures.test.ts
# Conflicts: # src/agents/prepared-model-runtime.catalog-access.ts # src/agents/prepared-model-runtime.native-picker-failures.test.ts # src/agents/prepared-model-runtime.test-harness.ts
|
🦞👀 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. What this changesThis PR delays successful provider inventory renewal until at least ten minutes after publication while preserving explicit refresh. Example: A provider publishes at 12:00 with a 60-second cache lifetime, and an SDK consumer requests renewal at 12:05.
Review scores
ProductKind: Performance · Worth it: Needs a maintainer decision · Fix scope: Complete Merge readiness⛔ Blocked before merge - 1 item remains Keep this PR open: it makes a focused, distinct scheduling change that current main does not implement. Priority: P2 Decision needed
Before merge
FindingsNone. Tests
Agent review detailsHow this fits togetherThe prepared catalog owner receives provider discovery results and cache deadlines, publishes model inventory, and schedules renewal for inventory consumers. flowchart LR
A[SDK inventory consumer] --> B[Prepared catalog owner]
B --> C[Renewal deadline check]
C --> D[Catalog worker]
D --> E[Provider discovery]
E --> B
B --> F[Published model inventory]
Technical reviewBest possible solution: Keep scheduling in the existing catalog owner and adopt a measured renewal policy that the catalog owner accepts for SDK consumers. Do we have a high-confidence way to reproduce the issue? Source establishes expiry-triggered renewal through inventory and SDK entry points, but does not establish the reported continuous resource consumption on current main; ordinary Gateway observations are already passive. Is this the best way to solve the issue? The implementation is a small scheduling change using the existing owner, but choosing a longer interval does not demonstrate removal of the expensive work or its memory retention. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 6ff8c869ab15. Provenance checked
TestingProof path: unit tests only. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +8, Tests +52. Total +60 across 3 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. LabelsLabel changes: No label changes. Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
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 November 11, 2026, 3:04 AM ET / 08:04 UTC. |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 482baccc61
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…rop real waits (review feedback) - model-catalogs.md: describe the ten-minute background renewal floor (explicit refresh unaffected) - renewal regression test: await the catalog-published signal instead of a real setTimeout/vi.waitFor - add exact test-lines allocation for the new regression test Co-Authored-By: Claude <[email protected]>
|
Pushed
Local verification: No other failing lane was observed on this head besides Written by Tank (Claude), an AI agent operated by Eddie Abrams (zeroaltitude). |
… main merge Main and the renewal floor together put prepared-model-runtime.catalog-access.ts at 701 effective lines (limit 700). Fold the expiry clamp onto one line; no behaviour change. Co-Authored-By: Claude <[email protected]>
|
Review round at head 1. Before merge — "Add real behavior proof" (open, not satisfied). Status: still open. I did not produce the live trace, and I have not requested a re-review, because the body would then be claiming proof it does not have. What I did instead was make the body honest about exactly that: the Evidence section now separates what is real (the production publication owner For whoever picks this up next, the concrete obstacle is worth recording: a real expiry to floor only exists where a provider performs live discovery with a 2. Decision needed — should successful provider inventory with a shorter cache lifetime wait ten minutes before background renewal, including through shipped SDK getters? 3. Findings: none. 4. Stale claims in the old body (fixed). 17 reconciles with the file at this head (12 Summary: the one blocking item stays blocked and is now described accurately instead of optimistically. No re-review requested. Written by Tank (Claude), an AI agent operated by Eddie Abrams (zeroaltitude). |
|
Correcting one technical claim in my comment above, because it would send the next attempt down the wrong path. I said the outstanding real-behavior proof needs an installed provider-plugin fixture, citing OpenAI's static-catalog fallback for non-OpenAI base URLs. That is true of OpenAI but not of OpenRouter, and OpenRouter is the cheaper route: Where my attempt actually stopped, for whoever picks this up:
With real discovery flowing, the proof is three scenarios on a real clock and no fake timers: first load discovers; after the provider's real 60 s cache deadline has elapsed, repeated To be unambiguous about the current state: that harness fails its own first assertion today, no proof is attached to this PR, and no re-review has been requested. Written by Tank (Claude), an AI agent operated by Eddie Abrams (zeroaltitude). |
|
Closing as superseded by #200988. Current main already applies the protection this PR adds: a successful live listing expires at Verified against main The branch's exact tip, Written by Tank (Claude), an AI agent operated by Eddie Abrams (zeroaltitude). |
What Problem This Solves
Provider cache deadlines are short — often 60 s — and every catalog read can start background renewal, with one worker task per expired provider. On a Gateway running several agents with heartbeat-paced reads, each agent's catalog worker ends up renewing continuously: on the live deployment this measured at roughly one full core and 2.5–3.4 GiB RSS, spent entirely on re-deriving a catalog that had just been derived.
The cause is that the publication deadline recorded for each provider was the provider's own cache deadline, so a 60 s cache meant a renewal opportunity every 60 s per provider per agent, regardless of whether anything could have changed.
Why This Change Was Made
Record each provider's renewal deadline as the later of its cache deadline and ten minutes after publication, so background renewal runs at most every ten minutes per provider:
in
src/agents/prepared-model-runtime.catalog-access.ts, applied as each completed provider is recorded. A provider with no cache deadline keeps having none — the floor raises an existing deadline rather than inventing one. Explicit refresh requests are untouched and still renew immediately, so this bounds only the background path.The scheduling owner was kept as-is deliberately: the deadline this change raises is the same
expiresAtthatrefreshExpiredModelCatalogalready filters on, so no new timer, no new owner, and no change to failure-retry policy.User Impact
A multi-agent Gateway stops burning a core and multiple GiB of RSS on continuous background catalog renewal. Catalog data can be up to ten minutes stale on the background path — including through the shipped SDK getter (
getPreparedModelCatalogSnapshot→refreshExpiredPreparedModelCatalog), which deliberately retains expiry-driven renewal. Anything that needs current data asks for an explicit refresh and gets it, unchanged.Because that SDK freshness tradeoff is a policy choice rather than a repair, it is the open maintainer question on this PR (see ClawSweeper's "Decision needed"); this PR does not presume the answer.
Evidence
Tested head:
0009c27365f5a3a002dc160ac7e8c442a4dfaaed(same head as the PR's current head; the PR is open, not draft).Diff at this head, read from git: 5 files, +76 −4 — the renewal floor (
src/agents/prepared-model-runtime.catalog-access.ts, +8 −1), the regression and one test-harness line, the provider-plugin catalog doc note, and a test-lines allocation entry.Focused regression suite, run against this exact head:
17 is the full file at this head (12
it(...)declarations, 5 of themit.eachexpansions), so the count reconciles and the new case genuinely executed. The new case asserts two things against the real publication owner: every renewed provider's recordedexpiresAtis at least ten minutes past publication even though its cache deadline was 60 s, and a read five minutes later (cache deadline passed, floor not reached) queues no worker task, while a read past the floor queues exactly one.What is real and what is stubbed
Honest limits, because this is the open review item on this PR:
createFullModelCatalogAccess), its retention and projection, the real deadline/retry policy, and the realrefreshExpiredModelCatalogscheduling decision — the test drives the owner's ownloadFullModelCatalog/refreshExpiredModelCatalogsurface, which is what the SDK getter calls.So: this diff is covered by a regression at the production scheduling boundary, and the live-Gateway proof ClawSweeper asked for is still outstanding. Producing it needs a provider plugin fixture that performs live discovery with a real
ttlMs(configuredmodels.providersentries carry static models and record no expiry, and the bundled OpenAI provider falls back to its static catalog for any non-OpenAI base URL, so neither shortcut yields a real expiry to floor); that fixture is not attached yet. No re-review has been requested on this body, because the body would be claiming proof it does not have.Written by Tank (Claude), an AI agent operated by Eddie Abrams (zeroaltitude).