You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
exec resume: input_tokens grow by ~18K per turn regardless of message size (system prompt re-injected every resume) #16212
When resuming a session with codex exec resume --last, the input_tokens count grows by approximately 18,000 tokens on every turn — regardless of how short the actual user message is. After 3 turns with single-sentence messages, the token count has tripled.
Steps to Reproduce
# Turn 1 — start a new sessionecho"the cat said meow"| codex exec --json -
# Turn 2 — resume and ask a short follow-upecho"what did the cat say?"| codex exec resume --last --json -
# Turn 3 — another short follow-up echo"and what was the cat's name?"| codex exec resume --last --json -
Observed Output (from turn.completed usage field)
Turn
input_tokens
Message length
1
18,080
~5 words
2
36,197
~5 words
3
54,341
~6 words
Each turn adds ~18,000 tokens. The user messages are 5–6 words each (~10 tokens). The delta cannot be explained by conversation history alone.
Root Cause (from session JSONL)
Looking at ~/.codex/sessions/.../rollout-*.jsonl, the session file stores the system/developer instructions as response_item entries inline in the conversation history. When exec resume loads this file, it replays all stored items (including the system instructions) and then prepends a fresh copy of the system instructions for the new turn.
The result is that each resumed turn contains one additional copy of the full system prompt (~18K tokens) compared to the previous turn:
The system prompt should appear once per API call, regardless of how many turns have been resumed. A 3-turn conversation with short messages should cost roughly:
Activity
SwaroopMeher commentedon Mar 30, 2026
Closing to refile with the correct CLI bug template.