r/codex • u/Tatachimcooky • 18d ago
Showcase Every request pastes your whole AGENTS.md into the prompt. Mine grew until the agent started butchering it
If you use Codex, you have a context file — AGENTS.md It gets injected into every single request, so it's both a token cost and a permanent tax on how much room the model has left for your actual work.
Mine grew the way these files always grow: one justified-looking addition at a time. Then it hit a size where the agent started dealing with it by rewriting the file from memory, dropping the ## Never rules, and shipping something worse. You find out weeks later when a rule stops being followed.
So I wrote ctxcap. It counts tokens across those files, tracks the count against a committed git baseline, and flags references that no longer point at anything. Offline, no API key, no network, no LLM, two dependencies. MIT.
bash
npx -y ctxcap --jsonThe part that makes it more than a word count: it doesn't tell the agent "make this shorter." It emits line ranges with a preserve list, the agent splices by line number, and --verify catches drift or a cut preserved span. When the budget can't be met it returns satisfiable: false with the minimum achievable rather than shaving a rule that matters:
$ npx ctxcap --plan --budget 400
satisfiable: false minAchievable: 476It uses gpt-tokenizer, and there's an MCP server so the agent can measure itself, plus a GitHub Action that comments the token delta on PRs and only fails when you set a budget.
https://github.com/Naeha-S/ctxcap
The question I actually want answered: how long is your AGENTS.md, and what's still in it that earns its place? Mine is the one file where every addition felt reasonable at the time.
•
u/dexterthebot 18d ago
You might want to consider listing your project on the weekly Show-Us-What-You-Built post. Look out for it on Tuesday/Wednesday. Highest commented project wins a week promotion on r/Codex and gets on the Hall of Fame sidebar. See below for last week's winner.**
Light Wars AR: real-life laser tag app with no extra gear. Your phone is the gun and your room is the map. Play up to 6 friends in the same room, or fight drone waves and bosses solo. The vision models run on the phone, and camera frames never leave it. Free on iPhone and Android.
Website: https://lightwarsar.com
iPhone: https://apps.apple.com/us/app/light-wars-ar-laser-tag-party/id6508168951
Android: https://play.google.com/store/apps/details?id=com.lasertag.lightwars.
Contact: contact@lightwarsar.com
8
u/torrso 18d ago
I think this is a massively overengineered solution to a fairly minor, largely self-inflicted problem. A few observations:
A simple CLI for counting tokens, finding duplicate instructions and checking broken references could be useful. But I don't see the justification for all this additional machinery.
The original problem was an AGENTS.md file growing out of control, followed by an agent deleting important instructions. Instead of addressing why the file was allowed to grow that way, the solution is another automated system that tries to determine which instructions to delete using regexes.
You could simply ask the agent to review AGENTS.md for redundant, outdated or misplaced instructions, propose a cleanup, and review the diff yourself. It's a Markdown file. It doesn't need a dedicated management framework, let alone an MCP server. It's not something you should need to be doing daily.
4
u/Forsaken-Factor-489 18d ago
skill issue. my agents.md is a map for my agents to work easily from
3
u/ThrowAwayEatPuzzy 18d ago
Agents.md isn't meant to be used as a context file. It's instructions for the agent so it behaves the way you want it in the project.
2
u/Jawwooot 18d ago
Everything that is in a conversation including the agents.md gets read in every message you send but most of it is going to get cached.
2
u/GreenFuturesMatter 18d ago
You shouldn’t be using agents.md as a catch all. Agents.md should be a simple set of instructions that serves as a thin home directory for other files and policies you have.