Skip to content

Codex cost history can misattribute long gpt-5.5 sessions to gpt-5 #1013

Description

@hhh2210

Summary

CodexBar 0.26.1 can show a large gpt-5 cost/token bucket even when the local Codex session JSONL only records gpt-5.5 turns.

Reproduction evidence

On a local Homebrew-installed CodexBar 0.26.1 build, the cost history tooltip showed for 2026-05-18:

  • gpt-5: about 22M tokens / $5.59
  • gpt-5.5: about 3.8M tokens / $3.72

The generated cache at ~/Library/Caches/CodexBar/cost-usage/codex-v6.json had the same split:

"2026-05-18": {
  "codex-auto-review": [97987, 48256, 145],
  "gpt-5.5": [3826443, 3471104, 6845],
  "gpt-5": [21808861, 20239872, 109701]
}

But scanning the raw ~/.codex/sessions/2026/05/18/*.jsonl files directly showed turn_context models as gpt-5.5 / codex-auto-review, with only one zero-token fallback attribution to gpt-5.

Likely cause

CostUsageScanner.parseCodexFile allows Codex lines up to 256 KiB, but only retains a 32 KiB prefix. Current Codex turn_context rows can exceed 32 KiB. One real turn_context row was 33,922 bytes and contained payload.model = gpt-5.5. When that row is treated as truncated and skipped, subsequent token_count events without an explicit model fall back to gpt-5, causing the cost history to over-report gpt-5.

Expected behavior

Long turn_context rows should still preserve model attribution for following token_count events, and existing bad Codex cost caches should be invalidated so the UI recalculates the corrected model split.

Version

Observed with Homebrew-installed CodexBar 0.26.1. The same prefixBytes = 32 * 1024 pattern is still present on current main as of 2026-05-18.

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