Repository navigation
fix(cron): retain run-owned pricing through finalization - #139374
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. |
Resolve token-only scheduled usage against the selected agent directory and retain the prepared metadata scope through accounting, delivery, and cleanup. Close the existing lease once and fence detached borrowing after release. Extracts the focused cron finalization repair from #130706. Production LOC net -8; verified worker-local pricing and model reload/control through a real Gateway and OpenAI inference.
d5b9bd3 to
1e18d5c
Compare
|
Codex review: needs maintainer review before merge. Reviewed September 5, 2026, 5:06 PM ET / 21:06 UTC. ClawSweeper reviewWhat this changesThe PR keeps scheduled runs’ selected runtime metadata through accounting and cleanup, and uses the selected agent’s local prices when estimating token-only usage. Merge readiness✅ Ready for maintainer review This remains a useful, focused repair: current main still loses selected-agent pricing and leaves the retained metadata scope before finalization. No blocking introduced defect was found. Priority: P2 Review scores
Verification
How this fits togetherThe cron scheduler prepares an agent runtime, executes a scheduled turn, then records usage and delivers its result. Finalization needs the same agent directory and model metadata used by that run. flowchart TD
A[Scheduled job] --> B[Prepare selected agent runtime]
B --> C[Execute agent turn]
C --> D[Finalize usage and result]
E[Agent prices and retained metadata] --> D
D --> F[Persist accounting and deliver]
F --> G[Clean up and release runtime]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource -8, Tests +120, Docs +2. Total +114 across 4 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep accounting, delivery, and cleanup inside the run’s existing metadata lifetime, with selected-agent pricing and one final release. Do we have a high-confidence way to reproduce the issue? Yes, from source: token-only cron usage can resolve the wrong agent’s prices, and finalization runs outside the selected metadata scope on current main. Runtime reproduction was not executed during this read-only review. Is this the best way to solve the issue? Yes. Supplying the prepared agent directory and extending the existing scope fixes the owning boundary; a new pricing resolver or finalizer-only workaround would duplicate behavior or leave cleanup outside that lifetime. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against f8b43dc795f2. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Merged via squash.
|
…9374) Resolve token-only scheduled usage against the selected agent directory and retain the prepared metadata scope through accounting, delivery, and cleanup. Close the existing lease once and fence detached borrowing after release. Extracts the focused cron finalization repair from openclaw#130706. Production LOC net -8; verified worker-local pricing and model reload/control through a real Gateway and OpenAI inference.
What Problem This Solves
Scheduled runs that report token usage without a monetary total can lose their cost estimate in a fleet, even when the selected agent has prices in its own
models.json. Cron's finalizer omitted the selected agent directory when resolving those prices. A separate owner-boundary regression also showed finalization using an ambient alias policy after inference had left the selected runtime's metadata scope.This extracts the useful cron finalization repair from #130706.
Why This Change Was Made
The existing prepared runtime now spans inference, accounting, delivery, and cleanup, with one final release that fences detached borrowing. Cost lookup receives the agent directory already selected during preparation. This keeps the repair in cron's existing owner and removes duplicated release paths.
Production LOC: +280/-288, net -8. Tests: +121/-1. Documentation: +2. Most of the run-file diff moves the existing body into its retained scope.
User Impact
Token-only automation results use the scheduled agent's local model prices, and final bookkeeping uses the metadata selected for that run. The change adds no configuration, protocol, or database surface.
Evidence
Both added regressions failed before their corresponding repairs: an explicit fleet with separate main/worker price files completed with an undefined estimate instead of the worker's $3; a different ambient alias policy also cleared the expected $3 estimate. The pricing resolver and local model files are real in these tests; inference is the existing cron runner harness.
/readyzand rerun successfully. Earlier fixture attempts were corrected to use supported credential loading, declared startup activation and exact no-tools enforcement.The rebase onto
9c068e13bd187606cac6111d60700f09ef52bd89preserves upstream Workshop execution-root plumbing and rejection handling. The pricing/lifetime repair and its production LOC delta are unchanged; the 159-test run and fresh review cover that integration. No fresh live run on the rewritten head is claimed.Release-note context: fix automation cost estimates for selected agents with local model pricing and retain the run's metadata through finalization.