Skip to content

First message in fresh session consumes ~100k input tokens immediatly, no matter how trivial the input #18526

Closed

Description

@afolkest

What version of Codex CLI is running?

0.121.0

What subscription do you have?

Pro

Which model were you using?

gpt-5.4 xhigh and gpt-5.3-codex-spark high

What platform is your computer?

Darwin 24.6.0 arm64 arm

What terminal emulator and version are you using (if applicable)?

iTerm2

What issue are you seeing?

Whenever I open a fresh Codex session and send a simple message, it consumes about 102k-105k tokens immediately.

What steps can reproduce the bug?

Input:
codex exec "Say hello world"

Output:

OpenAI Codex v0.121.0 (research preview)
--------
workdir: <redacted>
model: gpt-5.4
provider: openai
approval: never
sandbox: workspace-write [workdir, /tmp, $TMPDIR, /Users/<redacted>/.codex/memories]
reasoning effort: xhigh
reasoning summaries: none
session id: 019da3a1-d1d5-7a22-950b-3839f72b8e20
--------
user
Say hello world
codex
hello world
tokens used
105,156
Image

What is the expected behavior?

No response

Additional information

No response

Activity

  1. added
    CLIIssues related to the Codex CLI
    execIssues related to the `codex exec` subcommand
    rate-limitsIssues related to rate limits, quotas, and token usage reporting
    on Apr 19, 2026
  2. etraut-openai commented on Apr 19, 2026

    @etraut-openai
    Contributor

    You must have a very large AGENTS.md or a large number of MCPs. You should look at the rollout file (you can ask codex to find it for you under ~/.codex/sessions).

    When I try to repro the problem (with relatively few MCPs and a minimal AGENTS.md file), I see a value of about 22K tokens usage for the first prompt.

  3. afolkest commented on Apr 19, 2026

    @afolkest
    Author

    I reproduced this issue in a freshly initialized empty repo with no AGENTS.md and with my MCPs removed from Codex.
    I went ahead and downgraded Codex to 0.115 and the problem is gone. Looking at the rollout file I see nothing corresponding to 100k tokens.

    The issue showed up immediately after upgrade to 0.121 with no other changes in my setup.

  4. quark-zju commented on Apr 19, 2026

    @quark-zju

    Could it be the "memories" feature? I noticed that after enabling "memories", codex tries to summarize past sessions into memories, which consumed a lot of tokens. The raw_memories.md is also 3.4k+ lines, which seems to be too long to be injected in context. I have to disable the memories feature entirely.

  5. etraut-openai commented on Apr 24, 2026

    @etraut-openai
    Contributor

    @afolkest, are you still seeing this with the latest version of the CLI? We did discover a regression that made it in to 0.121 that could have explained what you were seeing. We fixed it shortly after, and the fix was in 0.122.0 and all subsequent versions.

  6. afolkest commented on Apr 24, 2026

    @afolkest
    Author

    @etraut-openai It appears to be fixed now! Many thanks for getting back to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingexecIssues related to the `codex exec` subcommandrate-limitsIssues related to rate limits, quotas, and token usage reporting

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions