Files
magpie/internal/sessions/testdata/codex-fork-replay-checkpoints.jsonl
T
yetone ec15f87393 sessions: a Codex Desktop fork's replayed parent checkpoints book no usage, so a thread_spawn session isn't counted ~1000x (#2234, zlxdengtianhei)
A token_count event that can't be paired with a response record fell
back to the cumulative total's delta whenever a previous total existed,
even when the event's own last_token_usage was there. A Codex Desktop
subagent fork (thread_spawn) writes two cumulative counters into one
rollout: its parent's, replayed with last=0, and its own. Each switch
from the fork's lower counter back up to the parent's booked the gap,
tens of millions of tokens, as one call. The reporter's day read 187.4B
tokens where ~10.3B was real.

last_token_usage is the request's own usage, exact even when zero, so it
is used whenever it is valid; only a missing or invalid last falls back
to the delta, and with no previous total to the total itself, as before.

Run:
- TestCodexUsageForkReplayCountsOnlyLast (new), on the reporter's own five
  lines (testdata/codex-fork-replay-checkpoints.jsonl, numbers untouched),
  checking both Calls and the session summary. Old code: FAIL "calls
  booked {Input:832145 Output:281374 CacheRead:82834688 ...}, want
  {Input:3273 Output:1201 CacheRead:72448 ...}". New: PASS, on macOS and
  on the Windows box with every TestCodex* test.
- TestCodexUsageUnpairedCountKeepsLegacyDelta and the other Codex usage
  tests still pass; go test -tags nogui ./... on macOS with this series:
  every package ok.
- gofmt -l, go vet ./... on darwin, linux (nogui) and windows: clean.

Not run: a reindex of the reporter's full dataset; the numbers above are
from their excerpt.
2026-10-15 03:34:58 +08:00

6 lines
2.7 KiB
JSON

{"timestamp":"2026-07-28T21:54:45.895Z","ordinal":0,"type":"session_meta","payload":{"session_id":"019fa314-0000-7000-8000-000000000000","id":"019faab9-0000-7000-8000-000000000001","forked_from_id":"019fa314-0000-7000-8000-000000000000","parent_thread_id":"019fa314-0000-7000-8000-000000000000","timestamp":"2026-07-28T21:54:40.644Z","cwd":"/tmp/repro","originator":"Codex Desktop","cli_version":"0.146.0-alpha.3.1","source":{"subagent":{"thread_spawn":{"parent_thread_id":"019fa314-0000-7000-8000-000000000000","depth":1,"agent_path":"/root/repro","agent_nickname":"repro","agent_role":null}}},"thread_source":"subagent","agent_nickname":"repro","agent_path":"/root/repro","model_provider":"openai","base_instructions":{"text":"x"},"history_mode":"paginated","subagent_history_start_ordinal":573,"multi_agent_version":"v2","git":{"commit_hash":"0000000000000000000000000000000000000000","branch":"main","repository_url":"https://github.com/example/repro.git"}}}
{"timestamp":"2026-07-28T21:54:45.895Z","ordinal":2,"type":"event_msg","payload":{"type":"token_count","info":{"total_token_usage":{"input_tokens":855011161,"cached_input_tokens":838592256,"cache_write_input_tokens":0,"output_tokens":2876802,"reasoning_output_tokens":553775,"total_tokens":857887963},"last_token_usage":{"input_tokens":0,"cached_input_tokens":0,"cache_write_input_tokens":0,"output_tokens":0,"reasoning_output_tokens":0,"total_tokens":18010},"model_context_window":258400}}}
{"timestamp":"2026-07-28T21:54:45.895Z","ordinal":7,"type":"event_msg","payload":{"type":"token_count","info":{"total_token_usage":{"input_tokens":771420049,"cached_input_tokens":755830016,"cache_write_input_tokens":0,"output_tokens":2596629,"reasoning_output_tokens":518322,"total_tokens":774016678},"last_token_usage":{"input_tokens":75721,"cached_input_tokens":72448,"cache_write_input_tokens":0,"output_tokens":1201,"reasoning_output_tokens":394,"total_tokens":76922},"model_context_window":258400}}}
{"timestamp":"2026-07-28T21:54:45.895Z","ordinal":2,"type":"event_msg","payload":{"type":"token_count","info":{"total_token_usage":{"input_tokens":855011161,"cached_input_tokens":838592256,"cache_write_input_tokens":0,"output_tokens":2876802,"reasoning_output_tokens":553775,"total_tokens":857887963},"last_token_usage":{"input_tokens":0,"cached_input_tokens":0,"cache_write_input_tokens":0,"output_tokens":0,"reasoning_output_tokens":0,"total_tokens":18010},"model_context_window":258400}}}
{"timestamp":"2026-07-28T21:54:45.895Z","ordinal":8,"type":"event_msg","payload":{"type":"item_completed","thread_id":"019faab9-0000-7000-8000-000000000001","turn_id":"rollout-2","item":{"type":"AgentMessage","id":"item-9","content":[{"type":"Text","text":"x"}],"phase":"commentary"},"completed_at_ms":1785275685895}}