Codex CLI token usage: reading it, then lowering it
Codex tells you what it spent after the fact. Here is how to see it beforehand, and what moves the number.
Codex CLI sessions have the same shape as any agent session: a small question wrapped in a large amount of context. What differs is that a meaningful part of that context is ambient. It is there before you type anything.
Ambient input: the part you did not ask for
Every session starts with instructions, tool schemas, and whatever the environment has registered. None of it is wrong, and all of it is billed on every turn, whether or not the current task touches any of it.
This is measurable without spending quota, which is unusual and worth knowing about:
codex debug prompt-inputPrints what would be sent. Deterministic, repeatable, and it costs nothing.
Run it on your own machine and read the total. On our reference machine, the ambient portion that capsul removes came to a little over four and a half thousand tokens per turn: a plugin catalogue, connector instructions and bundled skills, plus the tool schemas of the MCP servers Codex started on its own.
Session input: the part you can control
On top of ambient input sits the same thing every agent accumulates: files read, commands run, and the transcript so far. The levers are the ones that work everywhere.
- Name the file rather than letting the agent find it.
- One session per task, closed when the task is done.
- Filter noisy command output before it reaches the transcript.
- Put a ceiling on context and keep it there.
Running Codex under a budget
capsul drives the Codex CLI you are already signed into, so your existing ChatGPT plan is what answers. Continuation, usage and reasoning effort are reported back where you can see them.
npm i -g @penra/capsulcapsul ask 'add pagination to the search endpoint' --budget 3000Reading the numbers honestly
Two cautions that apply to every token benchmark, including ours. First, weighted input and raw input are different measurements: cached input is billed at a fraction of fresh input, so a comparison that ignores caching flatters whichever arm caches better. Second, a saving on one task is not a saving on the next. Our own table has a row where capsul uses more weighted input, and it is published rather than dropped.
Questions
How do I see Codex token usage without spending quota?
codex debug prompt-input prints what would be sent for a given input without calling a model. It is deterministic, so you can measure a change by running it twice.
Does capsul need an OpenAI API key?
No. It drives the Codex CLI you are already signed into, so your ChatGPT plan is what answers. An API key is an optional per-session choice on any plan.
Does reducing input change the reasoning effort?
They are independent. Effort is a separate setting, reported back into capsul alongside usage, and you can set it per request.
Do MCP servers cost tokens even when unused?
Their tool schemas are part of what gets sent, so yes, a registered server that the current task never touches still occupies input on every turn.
$ npm i -g @penra/capsul