[Bug]: Usage double-counts copied history in forked Codex rollout files #5758
Before submitting#
- I searched existing issues and did not find a duplicate.
- I included enough detail to reproduce or investigate the problem.
Area#
apps/server
Steps to reproduce#
- Use Codex with sessions that create forks or subagent threads.
- Confirm that a child rollout contains its own
session_meta, followed by a copied parentsession_metaand parent history. - Configure T3 Code to read that Codex home.
- Open Usage and select a window that includes the parent and forked sessions.
- Compare the processed token total with
ccusagefor the same Codex home and date range.
On my 30-day window, T3 reported 886B processed tokens and an estimated raw token cost of $600,406.69. A ccusage export for roughly the same period reported about 27.4B tokens and $21.1K.
T3 also showed large usage peaks from before I started using T3 Code, so this did not look like normal timing drift or recent token usage.
The forked Codex rollouts appear to explain the difference. A forked rollout can contain:
- The child session's
session_meta. - A copied parent
session_metaand the parent's history. - New records generated by the child.
The copied records can receive timestamps close to the fork time. Timestamp-based cross-file deduplication therefore does not identify them as copies.
In my transcript set, 275 forked or copied rollout files accounted for about 92% of the usage reported by T3.
I reproduced this against a frozen copy of the transcript data. A fork-aware recalculation and ccusage 20.0.19 both produced exactly 24,316,911,765 Codex tokens for that copy.
Expected behavior#
Usage copied from a parent rollout should only be counted once. A fork should contribute usage generated after the fork, not the parent's full history again.
Actual behavior#
T3 counts the copied parent history again for each forked rollout. This can multiply historical usage and place large peaks on the dates when the forks were created.
Later copied session_meta records can also replace the child session ID while T3 parses the file.
I also use a second Codex profile for Bedrock. It has a separate shadow home for authentication but shares the regular Codex state through the configured Codex home. I originally suspected that setup, but T3 appears to resolve the shared transcript directory once. It does not seem to be the source of the inflation.
Impact#
Major degradation or frequent failure
Version or commit#
main @ 89ee692b
Environment#
macOS 26.5.2, arm64, Node 22.18.0, Bun 1.3.14, Codex provider
Logs or stack traces#
No error is logged. The issue is visible in the aggregated Usage totals.
Screenshots, recordings, or supporting files#
No response
Workaround#
Use ccusage for Codex usage totals. There does not appear to be a way to exclude copied fork history from T3's Usage page.
t3dotgg(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.