Repository navigation
Description
Bug
On ccteam 0.11.0 (0214057d), a Codex session's tokens_total records its final model request instead of the native turn/session cumulative usage. This understates usage and makes cross-vendor session comparisons misleading.
This is the deferred accounting limitation noted in #197 (local docs-local/issues/#202, not GitHub #202). This issue supplies a concrete native cumulative record for the follow-up.
Observed evidence — no token estimates
Session s968, model gpt-6-astra, one delegated task, 30 native request usage records. At 2026-09-07T16:03:06.961Z, its final native token_usage_record contains:
{
"usage": {
"input_tokens": 122434,
"cached_input_tokens": 121600,
"output_tokens": 194,
"reasoning_output_tokens": 47,
"total_tokens": 122628
},
"turn_token_usage": {
"input_tokens": 2838308,
"cached_input_tokens": 2716416,
"output_tokens": 26140,
"reasoning_output_tokens": 5716,
"total_tokens": 2864448
},
"thread_token_usage": {
"input_tokens": 2838308,
"cached_input_tokens": 2716416,
"output_tokens": 26140,
"reasoning_output_tokens": 5716,
"total_tokens": 2864448
}
}The ccteam session metadata reports tokens_total: 122628. Its chat_turn_completed usage is {cached_input_tokens:121600,input_tokens:834,output_tokens:147,reasoning_output_tokens:47}, also summing to 122628. Native turn and thread totals are 2864448. The raw figures above come directly from the native record, not character-to-token conversion or inferred billing.
Cause
crates/ccteam-harness/src/execution/codex_app_server.rs, codex_last_request_usage_from_notification: retains tokenUsage.last and attaches it at completion. The source comment explicitly describes this as a lower bound pending a full accounting fix. Fixing the earlier camelCase parsing issue recovered nonzero usage but did not recover cumulative accounting.
Expected behavior / acceptance
- Session usage reflects the vendor-native thread cumulative statistics; task-turn usage reflects vendor-native turn cumulative statistics. Preserve current-context occupancy as a separate metric.
- Replay this fixture: session and task-turn total must be 2864448, not 122628.
- Use an authoritative native statistics source supported by the adapter; if live notifications do not supply the necessary scope, reconcile from native persisted statistics with explicit identity/freshness. Do not estimate missing usage or substitute the final request for a cumulative total.
- Test multiple requests within one turn, multiple turns, duplicate/out-of-order observations, daemon restart, release/resume and vendor thread replacement. Scope cumulative baselines by the native identity; do not sum cumulative snapshots or count usage twice after restart.
- Cached input is a subset of input; reasoning output is a subset of output. Preserve disjoint canonical accounting without adding either subset twice.
- Missing/incomplete native statistics remain explicitly unknown/incomplete. Failed/interrupted turns retain whatever authoritative usage is available without inventing a final total.
- Treat correction of existing ledger entries as an explicit, idempotent reconciliation; do not silently add a corrected cumulative figure to already booked usage.
No session prompts, source code, credentials, or private reasoning are needed for this reproduction.
Activity