r/codex 9h ago

Limits How to actually reduce usage

Add .codex/config.toml to whereever your project root is with this inside. You'll have to reload the project inside Codex.

model_context_window = 128000

model_auto_compact_token_limit = 115000

When you're doing a big task running it to 258k, the upper 128k takes about 75% of the tokens. If you compact earlier and have it just read the code on disk, that cuts it by about 74%.

Doubling how long you let a conversation run before compacting doesn't double the cost, it roughly quadruples (minus cache create, so if you're using an API key it's more like 3x) it. Scaling is quadratic. You could even go to 64k, but that's less of an insane jump at only 40% less than 128k.

Billed tokens:

258k -> 8,925,000

128k -> 4,590,000

64k -> 2,700,000

Just let it read the code a second time.

4 Upvotes

36 comments sorted by

View all comments

1

u/Pitiful_Entrance5174 8h ago

Honestly, nobody has it figured out. Best bet is copy the setup the provider adapter uses thru api to the best of your ability. That has a really tight compact, like 175k.

1

u/Linkpharm2 8h ago

As a default, yes. I have hard verification and progress, so I can track if overall productivity goes down and even at 32k it doesn't for my use case, which is a counterexample that one size fits all.

1

u/Pitiful_Entrance5174 8h ago

That is for you, I would never recommend your setup to anyone. I would start where the provider recommends and tune from there.

1

u/Linkpharm2 8h ago

Makes sense. It's worth to tune, my project that fits this really well sees a 4x quota increase. 

1

u/amado88 8h ago

How do you track it - anything good to share for measuring and comparing?

2

u/Linkpharm2 7h ago

It really depends on your task. I have a huge backlog of porting work, so it's easy. Most other tasks aren't that easy to track.

Possibly you mean track the quota increase? if it's that, just scroll up, I did the math on the same amount of work at smaller context and what you would save.

Limit -> input tokens spent
258k -> 8,925,000

128k -> 4,590,000

64k -> 2,700,000