Skip to content

ccusage double counts forked codex sessions #1349

Description

@kendonB

What happened?

As explained by codex

• ccusage is counting Codex transcript records as if they were unique API calls. On
this system, that is not valid.

The short version: Codex forked/subagent session files copy parent history into each
child JSONL. For 2026-06-21, I found 99 Codex session files, and 98 of them contain
the same parent session id. A large child file starts with two session_meta records,
one for the child and one for the parent, then immediately replays thousands of
token_count rows at the child creation timestamp. One file alone has 14,741
token_count rows and a cumulative total_token_usage ending at about 2.19 billion.

So bunx ccusage codex daily --since 20260621 --until 20260621 sees those copied rows
as same-day usage. I ran the equivalent native binary offline and it reports:

totalTokens: 44,867,297,211
costUSD: 33,780.93

That number is inflated because it is summing duplicated serialized history, not
actual sampling events. The better source is Codex’s logs_2.sqlite “post sampling
token usage” events, then matching those to the relevant last_token_usage entries.
Using that method, yesterday looked like about 13.52M actual tokens and roughly
US$16.32 at GPT-5.5 API pricing with cached-input pricing.

Steps to reproduce

fork codex the ccusage

Expected behavior

No response

Version

No response

Activity

  1. pullfrog commented on Jun 21, 2026

    @pullfrog
    Contributor
  2. github-actions commented on Jun 21, 2026

    @github-actions
    Contributor

    This issue was auto-closed. Issues from new contributors are auto-closed by default.

    Maintainers review auto-closed issues and reopen worthwhile ones. Issues that do not meet the quality bar in CONTRIBUTING.md may not be reopened or receive a reply.

    Keep the issue short, concrete, and written in your own voice.

    If a maintainer replies lgtmi, your future issues will stay open. If a maintainer replies lgtm, your future issues and PRs will stay open.

    See CONTRIBUTING.md.

  3. ryoppippi commented on Aug 31, 2026

    @ryoppippi
    Member

    Historical audit: this discussion was auto-closed by the legacy contributor gate. That closure did not assess technical importance.

    Audit result: resolved. A later merged change or the current main implementation covers this request. This item is kept for history and does not need to be reopened.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtriage:resolvedResolved by a later change or current implementation.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions