Skip to content

Bug: Local token usage & estimated cost are under-reported due to ignoring subagent rollout session logs #2193

Description

@qiuruiyu

Issue Description

Summary

CodexBar's local log parser under-reports the total daily/monthly token usage and estimated cost when users run complex tasks. This happens because CodexBar's local scanning logic relies solely on top-level session IDs registered in ~/.codex/session_index.jsonl and fails to scan rollout files generated by spawned subagents (child threads).

How to Reproduce / Technical Details

  1. Run a complex coding task in Codex CLI or Claude Code via the Codex MCP plugin that triggers agentic loops (where the model defines and spawns subagents).
  2. Codex CLI handles these subagents by creating separate execution threads. In the filesystem, they write their own session rollout logs under:
    ~/.codex/sessions/YYYY/MM/DD/rollout-<subagent-session-id>.jsonl
  3. Because these subagents are internal child threads, their session IDs are not registered in the top-level user session index ~/.codex/session_index.jsonl.
  4. CodexBar's local parser reads session_index.jsonl to locate files to parse. As a result, it completely bypasses the subagent rollout logs, leading to a massive gap in reported vs. actual token usage.

Real-world Example from Logs

On July 14, 2026 (local timezone UTC+8), I ran a task that spawned multiple subagents (Gauss, Hubble, Schrodinger, etc.).

  • Actual Usage (Direct Log Sum of all files in directory): 331M tokens with an estimated cost of $269.96.
  • CodexBar's Chart Output: 83M tokens with an estimated cost of $65.71.
The math behind the discrepancy:
  • The parent session (019f6137-a3e2-7c72-ace4-126c54369a4a) cost $60.07. Combined with minor VSCode / Exec sessions, it totaled exactly $65.71 (what CodexBar displayed).
  • However, the subagent sessions (Gauss costing $52.37, Hubble costing $52.04, Schrodinger costing $51.23) were completely ignored by CodexBar's scanner because their session IDs were missing from session_index.jsonl.
  • Note: Although the cloud-based "Weekly/Monthly Limit" percentage (fetched via browser cookies/API) correctly counted the subagent requests, the "Estimated Cost" charts, project list, and total token usage meters were under-reported.

Expected Behavior

CodexBar's local parser should scan all rollout-*.jsonl files present in the daily session folders or discover subagent sessions by parsing parent-child relationships (e.g. checking payload.source.subagent in session_meta lines of the parent rollout files) instead of relying strictly on session_index.jsonl.

System Environment

  • OS: macOS 14+ (Apple Silicon)
  • Codex CLI Version: 0.144.2 (or similar)
  • CodexBar Version: Latest (v0.33.0+)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions