Repository navigation
dispatch: record per-worker token usage - #194
Merged
Merged
Conversation
vu1n
marked this pull request as ready for review
October 13, 2026 02:59
Codex Review SummaryThis 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Dispatch verdicts lack worker token accounting; recorded per-worker usage lets fork-k and cross-model H5 validation relate reward to cumulative token budgets.
Each worker row and
dispatch.worker_summarybody now hasusage: nullor four nullable counters:input_tokens,output_tokens,cache_read_input_tokens, andcache_creation_input_tokens. Dispatch snapshots each worker's normalized session events once after selection and pull, including failed, errored, and unverified workers. The summary artifact copies that snapshot.The fold shares cost accounting's message deduplication and native-over-wire preference. A counter is null when any selected observation omits it or addition overflows; reported zero remains zero. Raw cumulative snapshots and legacy cost envelopes are excluded. Grades, winner selection, retry policy, critic accounting, and legacy cost JSON stay unchanged.
Recorded events cannot certify complete provider billing: producer lag, unreported calls, skipped malformed log records, and later spend by live workers remain possible. Documentation explains partial/full-budget checkpoints, all-worker totals, unknown coordinates, and avoiding repeated cumulative snapshots. No benchmark, paid experiment, merge, or deployment is included.
Before / after contract example (JSON output is tested; not visually verified):
{ "session": "w0", "score": 1.0, "passed": true, - "retries_used": 1, "status": "scored" } + "retries_used": 1, "status": "scored", + "usage": { "input_tokens": 30, "output_tokens": 0, + "cache_read_input_tokens": 0, + "cache_creation_input_tokens": null } }Verification at
0a0044c4d6d24ec92dfc05b00ecd843deb5c7f20:cargo test --locked --no-default-features --bin pillbox usage: 48 passed.cargo test --locked --no-default-features --all-targets: 981 passed, 6 ignored across unit and integration targets; no failures.cargo fmt --check,cargo clippy --locked --no-default-features --all-targets -- -D warnings, andgit diff --check: passed.observed_usage_nulls_incomplete_counters_without_losing_other_fieldsobserved_usage_distinguishes_missing_from_reported_zeroobserved_usage_reuses_cost_identity_and_source_preferenceobserved_usage_overflow_is_unknown_per_counterusage_is_snapshotted_once_after_all_retries_and_segmentsfailed_errored_and_unverified_workers_retain_usageusage_read_failure_leaves_selection_and_retry_behavior_unchangedrecord_worker_summaries_writes_an_artifact_to_each_worker_logverdict_json_is_the_documented_envelopeAll mutants ran only in a scratch worktree; no mutant changes remain.