Skip to content

Include archived Codex sessions in usage reports #1177

Closed

Description

@yashau

What do you want to change?

Make ccusage codex include archived Codex sessions by default when CODEX_HOME points to a Codex home.

Today the Rust adapter reads ~/.codex/sessions, but not ~/.codex/archived_sessions. I would like Codex home discovery to include both directories, while preserving the current behavior where a direct JSONL directory can still be used for saved codex exec --json output.

I opened an implementation PR at #1176, but it was auto-closed by the contributor gate.

Why?

Archived Codex sessions are still part of local usage history. Ignoring them makes token and cost reports look much lower than the real local history for users who archive conversations.

On my machine, the difference is large:

  • active sessions/: 18 JSONL files, about 289M total tokens
  • active + archived_sessions/: 51 JSONL files, about 1.66B total tokens

So the current default undercounts my Codex usage by excluding archived sessions.

How? (optional)

The implementation in #1176 does this in the Rust adapter:

  • Treat entries with sessions/ or archived_sessions/ as Codex homes.
  • Read both directories by default for Codex homes.
  • Keep direct JSONL directory behavior unchanged.
  • Deduplicate by relative JSONL path before parsing, with the active sessions/ copy winning over an archived copy.
  • Use the same discovery behavior in both the event loader and aggregate streaming path.

Validation from the PR branch:

  • cargo test --manifest-path rust/Cargo.toml --workspace codex -- --nocapture
  • cargo check --manifest-path rust/Cargo.toml --workspace
  • git diff --check

Activity

  1. github-actions commented on May 28, 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.

  2. 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

    triage: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