Repository navigation
refactor(cron): simplify completed prompt accounting - #149818
Conversation
|
🦞👀 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. Reviewed September 16, 2026, 2:58 AM ET / 06:58 UTC (Revision 2). ClawSweeper reviewWhat this changesSimplifies scheduled-run accounting around one ordered collection of completed prompts and releases the session snapshot with a correctly typed empty map. Merge readiness✅ Ready for maintainer review Keep open as a useful, maintainer-requested cleanup. The pinned patch preserves the accounting and ownership contracts, introduces no actionable correctness finding, and is not already present on inspected main. Priority: P3 Review scores
Verification
How this fits togetherOpenClaw’s scheduler runs agent prompts and may request a continuation after an interim acknowledgement. This accounting layer carries completed usage into billing, diagnostics, and the final run result, including when a later prompt fails. flowchart TD
A[Scheduled agent job] --> B[Execute prompt]
B --> C[Record completed prompt]
C --> D{Continuation needed?}
D -->|Yes| B
D -->|No or failed| E[Settle usage once]
E --> F[Persist billing and diagnostics]
F --> G[Finalize result and release snapshot]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource -86, Tests 0, Other -1. Total -87 across 6 files. View PR surface stats
Review metricsNone. Technical reviewBest possible solution: Keep completed-prompt facts owned by the executor and reuse the existing guarded settlement path without changing billing, delivery, or persisted formats. Do we have a high-confidence way to reproduce the issue? Not applicable: this PR refactors already-fixed accounting behavior; existing regression scenarios and reported Gateway observations cover the contracts it must preserve. Is this the best way to solve the issue? Yes: the patch removes duplicate snapshots and routes all accounting consumers through the existing executor-owned collection without adding a competing implementation. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 47d9a40df0af. 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)
|
|
Merged via squash.
|
Maintainer-requested follow-up to #149767 and #149697.
What Problem This Solves
Simplifies cron retry accounting, which retained duplicate execution snapshots and copied the same prompt state through several layers.
User Impact
No user-visible behavior change, configuration change, or migration. Completed usage still survives failed retries; original errors, per-prompt pricing, final-request context, and session ownership checks are preserved.
Why This Change Was Made
Each prompt returns its completed result directly. The executor owns one ordered collection of completed prompts and publishes a readonly view before continuation persistence, so success and error accounting consume the same facts. This removes the mutable result cache,
getState(), redundant model-selection fallbacks, and repeated parameter forwarding. The coordinator retains one settlement operation for diagnostics and guarded persistence.Session teardown still releases the full snapshot after delivery, using a correctly typed empty map instead of a cast that assigns
undefinedto a required field.Production code is reduced by 86 lines across four files. Two existing teardown assertions change; no tests or production seams are added.
Evidence
154 existing tests passed across nine accounting, retry, lifecycle, message-tool policy, model-switch, and fallback suites. Core typechecking and targeted typed lint passed. Isolated Codex review returned no actionable P0–P2 findings across both evidence passes.
The assertion-safety baseline shrinks by one entry because teardown no longer needs a cast. Local changed-file guards and the assertion-safety ratchet passed. The helper expanded to all 19 core test graphs; that duplicate local type sweep was stopped in favor of the same exact-head required CI checks running in parallel. The hosted live Gateway lane passed against commit
0af23d0861cf7146e4542b595cff858b757c4337: all ten allowlist cases across OpenClaw and Codex (empty,read,group:fs,r*,bash), plus five scheduler scenarios. The lane reported 12 passed tests and 21 unrelated skips. Workflow tooling was pinned by the run ate7989781acc9fb608a9f799ac80fb4473bb38859.The full production build passed. Two real isolated Gateway/public CLI cases against that build passed using a registered synthetic harness and loopback provider: retry preparation throws, and the harness returns an abort. Each persisted 33 tokens and $0.0000515, preserved the original error/diagnostic, emitted exactly one terminal webhook without leaking the interim acknowledgement, and completed fixture cleanup. This is live Gateway boundary proof with a synthetic provider; the hosted lane above supplies real model proof.
Required CI passed on the exact candidate commit, including all production/test typechecks and the required
openclaw/ci-gate. ClawSweeper completed source review on this head with no actionable findings.