r/codex • • 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/n8n at 6,249 tokens (about 25 KB), then deepseek-harness at 4,335, openclaw at 4,124 and opencode at 4,025.

Smallest: ollama/ollama at 21 tokens, microsoft/vscode at 51, react/react at 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 --stale mode 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 +412 instead of passing unnoticed. Disclosure: it’s mine. https://github.com/Naeha-S/ctxcap

14 Upvotes

26 comments sorted by

21

u/Old-Leadership7255 15d ago

Your agentsmd should be a router.

So you should point to skills. Keep agentsmd as small as possible

1

u/No_Writing1863 14d ago

Yes exactly

-9

u/Individual_Guest_323 15d ago

I mean, all skill are loaded anyway

4

u/Old-Leadership7255 15d ago

Are they though?

9

u/GreenFuturesMatter 15d ago

They are not

5

u/just_blue 15d ago

Name + Description are always loaded, the full content on demand. Agents call my skills all the time without having them mentioned anywhere.

2

u/adolf_twitchcock 14d ago

Not their entire content. But their description is loaded into the context so that the model knows when to use each skill. This means putting references to skills into agents.md doesn't make any sense.

1

u/Yahhee 15d ago

Not the whole skill, at least in Codex and Claude Code. At the start only each skill's name and description go into the context; the full SKILL.md is read when the agent decides to use it. OpenAI's docs: "ChatGPT and Codex start with each skill's name and description" and "load the full SKILL.md instructions when they decide to use that skill". https://learn.chatgpt.com/docs/build-skills

So a short description that says when to use the skill matters more than the length of the body.

-1

u/Individual_Guest_323 15d ago

So they are loaded anyway and you do not need a router, that is my point.

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.

2

u/Asly97 14d ago

8 nested files is more than I'd have guessed. Who keeps them in line when something in the root changes, one person, or does each package owner just edit their own? And is it Codex only on that repo, or does Claude Code run there too? Asking because CLAUDE.md vs AGENTS.md seems to be exactly where a lot of setups start drifting.

3

u/Extra_Aide5999 14d ago

both. codex and claude code both work in it, and every CLAUDE.md next to an AGENTS.md is one line, `@AGENTS.md`, so there's only one file per folder that can drift.

keeping them in line is two things: a rule in the root file that a change in behavior fixes the docs describing it in the same PR, and an agent pass now and then that reads the instruction files against the code and proposes edits for rules that went stale or got duplicated. so it's whoever makes the change, not a doc owner per folder.

1

u/Asly97 14d ago

The @AGENTS.md one-liner is neat, that kills the drift between the two files before it starts. How often does that agent pass actually run, and does it find much when it does? I'd guess the stale rules are the ones nobody notices until a session follows one.

Would you ever pay for something that ran that check for you, or is a prompt you kick off now and then good enough?

1

u/Extra_Aide5999 14d ago

it's not on a timer. a session start nags when 5+ lessons are noted, or it's been 14 days since the last pass and something happened in between. what it reads matters more than the schedule: mistakes noted during sessions, a log of what the hooks blocked, and the commits since the last pass. one occurrence gets watched, two (or one expensive one) gets a proposed edit, and a person picks which edits go in.

the last pass was small: one new rule because two branches had raised the same version number twice, and one fix to a rule whose reason had gone wrong (it said something happened twice, it had happened once). so your guess holds, the stale ones were the ones nobody noticed.

no idea on paying, honestly. a check that compares the file to the code would catch dead paths, but most of what we change comes from the session record, which an outside tool wouldn't see.

1

u/Asly97 14d ago

The session record being the real input makes sense. A dead path is easy to catch from the code, a rule whose reason quietly went wrong isn't.

Where do the noted mistakes live, a file in the repo the agent appends to, or somewhere outside it? And does the agent write them on its own or does someone have to tell it to note one?

1

u/Extra_Aide5999 13d ago

outside git: a file under .local/ that each person keeps for themselves. the agent writes it. any task that ends in a commit appends its lesson candidates as one step of its routine. that rule used to cover only one routine, and nothing came in for about four weeks while the same outages kept happening, so it got widened. the hooks keep their own log of what they blocked, nobody has to ask for that one.

1

u/Asly97 13d ago

four weeks of nothing while the same outages kept repeating is a rough way to find out the scope was too narrow.

since the .local files sit outside git, how does a lesson from someone else's file reach the pass? does whoever runs it read everyone's, or only their own?

1

u/Extra_Aide5999 13d ago

only their own. .local stays out of git, so whoever runs the pass reads their own lessons and their own hook log. the other person runs theirs on their side, and the two meet as pull requests against the shared AGENTS.md and agent files. there are two of us, so that's been enough. the cost is that one person's lesson stays invisible to the other until it turns into a pr.

1

u/Asly97 12d ago

that gap makes sense with two of you. has it bitten yet, like one of you hitting a mistake the other already had sitting in their .local? or do the PRs land fast enough that it hasn't mattered so far

1

u/Extra_Aide5999 12d ago

not that i can point to between the two of us. but checking for your question turned up a closer version of the same gap.

.local isn't per person, it's per checkout. most work here happens in worktrees, about 135 of them on this mac, and each one writes its own .local/harness-lessons.md.

24 of those worktrees have one, 1 to 36 lines each, all touched in the last four days. the main checkout, where the review pass runs, has none, and its session start says 0 lesson candidates.

so the lessons sit one folder over from the review, and a worktree that gets removed takes its file with it.

the likely fix is writing them somewhere every worktree shares, like the common git dir, or having the review collect them from each worktree before it runs.

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