pingdotgg / pingdotgg/t3code

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

Open Beginner friendly
#7,090 2 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
23k
Forks
5.9k
Avg merge
11h 14m
Merged PRs (30d)
357

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at UsageService.resolveTranscriptDirs in apps/server and inspect the Codex shadow-home layout elsewhere in the codebase, especially how sessions and archived_sessions are treated. Reproduce the Usage page comparison for a window containing archived work. Done means archived_sessions is scanned alongside sessions and archived transcripts contribute to the reported totals without bypassing the existing mtime and scan-cache behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
74/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.