Include token_count events in non-interactive session files
Resolved 💬 2 comments Opened Jan 22, 2026 by tedzhao26 Closed Feb 23, 2026
💡 Likely answer: A maintainer (etraut-openai, contributor)
responded on this thread — see the highlighted reply below.
What feature would you like to see?
Interactive sessions in Codex CLI don't emit token_count events to session JSONL files, making it impossible for third-party tools like @ccusage/codex to track token usage.
Current Behavior
When running Codex interactively (not via codex exec), the session files only contain:
session_metaturn_contextresponse_itemevent_msgwith types likeuser_message,turn_aborted
Missing: event_msg with payload.type: "token_count"
Expected Behavior
Based on issue #5276, Codex should emit token_count events like:
{
"timestamp": "...",
"type": "event_msg",
"payload": {
"type": "token_count",
"info": {
"total_token_usage": { "input_tokens": ..., "output_tokens": ..., ... },
"last_token_usage": { ... }
}
}
}
Environment
- Codex CLI: 0.88.0
- macOS Darwin 25.2.0
- Model: gpt-5.2-codex
Use Case
Third-party usage tracking tools (ccusage, etc.) rely on parsing session files to provide cost analysis without requiring API admin keys. Without token_count events, these tools report "No Codex usage data found."
Additional Information
I've verified this across multiple interactive sessions - none contain token_count events. The sessions were short but included both completed and aborted turns.
2 Comments
Update: After further testing, I found that
codex execmode does emittoken_countevents correctly:The issue appears to be specific to interactive TUI sessions - those don't emit
token_countevents to the session JSONL files, onlyuser_messageandturn_abortedevent types.This means
@ccusage/codexworks correctly forcodex execusage but not for interactive sessions.This feature request hasn't received any upvotes, so I'm closing it.