Skip to content

[Bug]: Usage page never scans Codex archived_sessions/, so archived sessions' usage silently disappears #7090

Open

Description

@jameswasher

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

  1. Use Codex interactively, then archive some sessions (rollouts move from ~/.codex/sessions/ to ~/.codex/archived_sessions/).
  2. Open the Usage page for a window covering that work.
  3. Compare the reported Codex tokens/cost against the transcripts actually on disk.

Observed behavior

UsageService.resolveTranscriptDirs resolves only <codexHome>/sessions for the Codex provider, so rollouts in archived_sessions/ are never scanned — even though the Codex shadow-home layout elsewhere in the codebase treats archived_sessions as a known shared directory alongside sessions.

On my machine the effect is dramatic:

  • ~/.codex/archived_sessions/ holds 2.7 GB, with 148 files modified inside the 30-day window, containing ~6,700 gpt-5.6-sol turn-context records — this is where nearly all of my real interactive Codex work lives.
  • The scanned ~/.codex/sessions/ retains only ~300 gpt-5.6-sol records; the rest of it is dominated by codex-auto-review traffic (~31,000 model records).
  • The Usage page therefore reports 177M priced Codex tokens ($131.09) for the window; the true interactive figure is several times that.

Compounding it, codex-auto-review has no LiteLLM rate, so the 885M tokens that are scanned price at $0.00 (the display side of that is tracked in #5799). Net result: Codex usage is doubly understated — most real usage is invisible, and most visible usage is unpriced.

Expected behavior

Usage should cover archived sessions: scan archived_sessions/ alongside sessions/. Transcripts are append-only and the existing mtime filter + (size, mtime) scan cache already bound the cost of the extra walk. At minimum, the page should disclose that archived sessions are excluded from the totals.

Activity

  1. nathanscain commented on Aug 20, 2026

    @nathanscain

    +1

    The codex-auto-review being left without pricing makes the raw token cost tracking questionable as that model isn't cheap and I have coworkers telling me it burns through there limits. Impossible to verify without detailed price tracking to know how much of the token usage is discounted due to caching.

  2. tlmader commented on Sep 4, 2026

    @tlmader

    I really want to know my actual Codex API spend without unarchiving all of my chats 😆

  3. Dropje97 commented on Nov 14, 2026

    @Dropje97

    Since #34829, this affects all delegated Codex work by default, not only sessions a user archives. T3 now calls thread/archive on each finished delegated Codex child, so Codex moves that child's rollout into archived_sessions/. codexUsageReader.directories still returns only <CODEX_HOME>/sessions, so the Usage page stops counting the child's usage.

    On our install, running nightly 4606 since 2026-11-13, there are now 132 rollouts in archived_sessions/. Every one of them was written by T3 for a delegated child. Over the same period, 42 new rollouts stayed in sessions/.

    As a local workaround, we return archived_sessions as a second directory from codexUsageReader.directories, after sessions. The usage summary already removes duplicate Codex records across files (sharedSessionsAcrossFiles), so a rollout that was scanned in sessions/ and then moved still counts once.

    A test covers this:

    1. Scan a 17-token rollout.
    2. Move it into archived_sessions/ and add a 23-token rollout that only exists there.
    3. The total is 40 tokens, both before and after a restart.

    #21666 covers more cases than this workaround, but its automated pipeline stopped.

    Measured and written by Claude (Opus 5.5) in T3 Code; posted with the owner's approval.

  4. nuuls commented on Nov 25, 2026

    @nuuls

    Still happening on 0.1.12-nightly.20261123.5151 (Linux). Delegated Codex workers make it much worse, as the previous comment describes.

    What happened: a lead thread sent a fix round to 67 delegated Codex children (gpt-6.2-astra), which ran from 02:34 to about 08:00 UTC. T3 archived each child when it finished, so its rollout moved to ~/.codex/archived_sessions/. In usage-scan-cache-v17.json, the latest row from those rollouts is at 02:40 UTC, six minutes into the run. Nothing after that was ever counted.

    Missing from the Usage page, 25 Nov from 02:00 UTC on:

    • 501M input tokens (486M cached) and 1.63M output tokens.
    • The page shows about $20 of Codex for that window. At the page's own per-token rates, the missing part is roughly $380.

    Over 23–25 Nov:

    • 301 rollouts now in archived_sessions/: 130 never appear in the scan cache, and 157 were cached only part of the way.
    • 2.37B input tokens (2.30B cached) and 10.1M output tokens in them were never read.

    The usage itself was real: the server-reported rate_limits.primary.used_percent in those same rollouts went from 87% to 100% of the weekly limit during the run.

    For anyone using delegated Codex workers, the Usage page currently shows only a small part of their Codex usage. It would be great if someone could finish or take over #21666.

    Measured and written by Claude (Opus 5.5) in T3 Code; posted with the owner's approval.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions