Repository navigation
fix(usage): refresh model prices after catalog writes - #146113
Conversation
Invalidate the written agent price index through the existing models.json owner. Remove unused preparation results and queue wrappers while preserving serialized writes and copied public results. Related: #130706.
|
🦞👀 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: blocked before merge. Reviewed September 12, 2026, 12:21 PM ET / 16:21 UTC (Revision 2). ClawSweeper reviewWhat this changesRefreshes cached local usage prices after an agent’s models.json is written, simplifies writer coordination, and adds regression coverage and documentation. Merge readiness⛔ Blocked before merge - 1 item remains This remains a useful fix with no blocking findings. The previous migration blocker is cleared: the changed state is process-local, and the persisted formats and storage operations are unchanged. Priority: P2 Review scores
Verification
How this fits togetherOpenClaw’s model catalog writer publishes agent-local model settings. Usage reporting reads those prices through a synchronous cache to estimate costs when recorded costs are unavailable. flowchart TD
A[Model configuration] --> B[Catalog planner]
B --> C[Serialized catalog writer]
C --> D[Agent models file]
C --> E[Invalidate agent price cache]
D --> F[Usage price lookup]
E --> F
F --> G[Local cost estimates]
Before merge
Agent review detailsSecurityNone. PR surfaceSource -33, Tests +57, Docs +4. Total +28 across 6 files. View PR surface stats
Review metricsNone. Stored data modelPersistent data-model change detected: Technical reviewBest possible solution: Keep price-cache invalidation with the successful catalog writer while preserving synchronous reads, agent isolation, and recorded billing totals. Do we have a high-confidence way to reproduce the issue? Yes, from source: warm an agent’s price lookup, publish changed models.json prices through the writer, then read again; current main retains the old cached entry. No runtime execution was performed in this read-only review. Is this the best way to solve the issue? Yes. Invalidating the existing cache at successful publication directly repairs its lifecycle without polling, a second persistence owner, or a format migration. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 2a1bc8be3db5. LabelsLabel 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)
|
|
@clawsweeper re-review The PR body now records storage compatibility evidence for the before-merge item. |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Maintainer compatibility review: addressed. The latest technical review confirms that the changed state is process-local, persisted contracts are unchanged, and no migration is required. I independently verified the unchanged planner/reader, SQLite catalog owner, config types and private file writer, alongside the passing byte-preservation checks. The remaining generated checklist contradicts that conclusion: its prose parser treats “without polling, a second persistence owner, or a format migration” as missing migration proof. This is a reporting false positive, not an outstanding data migration. No code, schema, baseline, or merge gate is being weakened; the normal native workflow will verify the completed review and required CI. |
|
Merged via squash.
|
Invalidate the written agent price index through the existing models.json owner. Remove unused preparation results and queue wrappers while preserving serialized writes and copied public results. Related: openclaw#130706.
Related: #130706, #142100.
What Problem This Solves
Fixes an issue where local usage estimates keep an agent's old model prices after OpenClaw successfully writes updated prices to its
models.json. The file contains the new rate, but an already-warm process continues returning the old cached rate.Why This Change Was Made
The existing models.json owner now holds the bounded price index and invalidates the written agent immediately after successful publication. Usage readers keep their synchronous, non-polling lookup. The same cut removes unused preparation result fields and one-caller wrappers, reducing production code by 33 lines.
User Impact
Subsequent local estimates use newly published agent prices without restarting the Gateway. Other agents retain their own cached prices, and recorded per-call costs retain their original amounts. The read-only planning path remains read-only.
Evidence
pnpm buildpassed. Four compiled scenarios exercised the real planner, catalog writer, and usage consumer: two-agent priming, publication and formatted cost, read-only planning, and warm reuse with caller-result isolation. No source imports or network requests occurred; all 12,092 build files and 2,130 observed module files remained unchanged.Storage compatibility: no migration is required. Existing data compatibility is preserved and verified: the models.json planner, catalog reader, SQLite catalog owner, configuration types, and private file writer are byte-identical to the base.
models-config-state.tscontains process-localglobalThis/Symbol.forcoordination with Maps, promises, and an async queue; it is not serialized or persisted. The public writer result remains{ agentDir, wrote }, the native state-schema guard passed unchanged at v17, and compiled read-only planning preserved exact file bytes.