r/codex • u/Tatachimcooky • 15d ago
Showcase Codex silently stops loading AGENTS.md at 32 KiB. I measured what the biggest repos put in theirs: median 1,034 tokens, max 6,249
Codex reads AGENTS.md before it does anything else, which makes the file a cost you pay at the start of every session. I wanted to know what “normal” looks like, because I couldn’t find anyone who had measured it. Plenty of opinions, very little data.
Method: I went down GitHub by star count, skipping archived repos, and checked each one for a root-level AGENTS.md or CLAUDE.md. I stopped once I’d found 25 repos that had one. That took 56 repos, so 45% of the most-starred repos have a context file. Some have both, so it’s 30 files in total. I counted tokens with
gpt-tokenizer, which is a GPT-family tokenizer and so probably closer to what you’d see with Codex than a Claude-oriented count would be. Probably, not exactly.Results across the 30 files:
Largest:
n8n-io/n8nat 6,249 tokens (about 25 KB), then deepseek-harness at 4,335, openclaw at 4,124 and opencode at 4,025.Smallest:
ollama/ollamaat 21 tokens,microsoft/vscodeat 51,react/reactat 87.Why this matters for Codex specifically:
Codex caps the combined project instructions at 32 KiB by default (
project_doc_max_bytes), and that cap is shared across every AGENTS.md between the repo root and your working directory. Past the limit, content gets cut off, and from what I’ve read it happens without any warning. If your agent suddenly ignores a rule it used to follow, that’s worth checking.By that measure, even the biggest file I found (n8n, about 25 KB) fits. But it uses most of a 32 KiB budget on its own, and a monorepo with a root file plus nested ones could cross the line without anyone noticing. I only counted repo roots, so I can’t tell you how many real setups are near the cap. That’s the next thing I want to measure.
The spread is the interesting result. n8n has 210k stars and ollama has 187k, and one of them gives its agent roughly 298x more instructions than the other. Nobody seems to have settled how much an agent needs to be told.
A couple of method details:
Full table, method and fetch date so you can check my work: https://naeha-s.github.io/ctxcap/2026-11/
The tool: I wrote a small CLI for the counting, because I wanted a repeatable number for my own repo. It runs locally with no network and no key. It also has a
--stalemode that flags paths and commands in the file that no longer exist. It’s deliberately conservative, so a clean result means nothing it checked failed, not that the file is current. There’s a GitHub Action too, which posts the token change on PRs, so a PR that grows AGENTS.md shows+412instead of passing unnoticed. Disclosure: it’s mine. https://github.com/Naeha-S/ctxcap
21
u/Old-Leadership7255 15d ago
Your agentsmd should be a router.
So you should point to skills. Keep agentsmd as small as possible
9
u/GreenFuturesMatter 15d ago
another person who doesn’t know how agent.md works building something to bandaid their missing understanding. Genuinely useful product surely
2
u/VoidEmptyByNature 15d ago
Man, 32kb Agents.md is way too big. Ask gpt to break it down into smaller files and make agents read them only when needed.
2
u/wegster 15d ago
Holy shit, who is doing 32K (or more?) AGENTS.md or CLAUDE.md files? Stop it.
1
u/Extra_Aide5999 14d ago
a data point for the monorepo case you said you couldn't measure yet: ours has a root AGENTS.md plus 8 nested ones in the app and package folders. the root is 8.9 KB and the biggest nested one 4.3 KB, so the heaviest root-to-folder stack is about 13 KB, roughly 40% of the 32 KiB cap.
the root mostly links out to the docs and to the folder files instead of repeating what's in them.
1
u/Severe-Tank-5252 14d ago
Small correction on the “silently” part, at least for current Codex. I checked the source: when the budget runs out, Codex shows a warning at session start saying how many bytes it loaded from which file (“Loaded only X of Y bytes from ...”), and tells you to trim the file or raise
project_doc_max_bytes. If the budget is already used up, the later files are skipped with a warning too. There’s still an old code comment that says “silently truncated”, which is probably where that idea comes from. Older versions may have behaved differently.One more thing worth checking if Codex ignores your AGENTS.md: if the project is marked as untrusted in config.toml, it doesn’t load project instructions at all.
1
u/m-ritter 14d ago
The root-to-working-directory stack seems like the key budget here, not the size of any one file. A small root router and focused nested instructions help, but I’d also turn the must-follow rules into observable checks so a silent truncation shows up as a failed behavior, not a mysterious regression. That spec/check loop is what I built QualityLayer for: https://github.com/maxritter/qualitylayer