Skip to main content

Module codex_context

Module codex_context 

Source
Expand description

How full a Codex thread’s context is, for the pane’s context meter.

codex exec --json reports only the thread’s running totals: three one-word turns read input_tokens 14,295, 28,608 and 42,939 (codex-cli 0.154.0), so its turn.completed is never a context size. Codex’s own session file ($CODEX_HOME/sessions/YYYY/MM/DD/rollout-…-<thread>.jsonl, the local date the thread started) records each model call’s usage:

{"type":"event_msg","payload":{"type":"token_count","info":{
  "total_token_usage":{"input_tokens":42939,…},
  "last_token_usage":{"input_tokens":14331,"cached_input_tokens":14080,…},
  "model_context_window":258400}}}
{"type":"turn_context","payload":{…,"model":"gpt-6-astra",…}}

last_token_usage.input_tokens is the last call’s whole prompt (cached included), and model_context_window the window Codex compacts against. After each host turn srv reads them and writes an agentmux_context frame into the pane’s stream, which the frontend reads for any provider (frontend/app/view/agent/context-reader.ts). A container pane’s session file is inside its container, so it gets none.