r/OpenaiCodex • u/Life_Assist5275 • Nov 02 '26
Bugs or problems Codex agent ignored repository instructions and consumed excessive token budget
I’m using Codex on a repository with explicit AGENTS.md rules covering delegation, scope control, review cost, and model usage.
During a bounded visual UI slice, the agent made these six operational mistakes:
- It allowed too many repeated
waitoperations for a subagent. - It launched reviews against the entire dirty workspace instead of limiting them to the current slice.
- It continued after the scope expanded instead of stopping and asking for direction.
- It repeated review/correction cycles for non-blocking warnings.
- It switched between multiple models—Terra, Luna, and Sol—even though the repository rules did not require model switching for this visual task.
- It initially claimed that the model changes were required by
AGENTS.md, then later acknowledged that this was incorrect.
The result was a significant increase in token consumption: approximately 9% in four minutes, 20% in eight, etc.., despite using medium effort and having explicit cost-control rules in the repository.
The agent eventually acknowledged that the issue was its orchestration rather than a required project rule.
I would like clarification on:
- Why Codex did not reliably enforce the repository’s
AGENTS.mdinstructions. - Whether model switching is automatic or agent-controlled.
- How to prevent workspace-wide reviews for bounded slices.
- Whether there is a recommended hard-stop or configuration mechanism to prevent repeated expensive tool calls.
2
u/RemoraEdge Nov 02 '26
Yup that’s common with all AI agents after some time.
It forgets. Gets focus on a specific task. Gets “dumb”
Large context size will do that and long running sessions. You need to handhold it and steer it back and reset control. Or start a new session
2
u/[deleted] Nov 02 '26
i ran into an issue kinda like this where the Agent deployed fellow Astra Subagents instead of SOL/Luna one time and it used 50% of my weekly budget in like 2 hours. hasnt happened again ever since i enforced SOL/Luna for subagent tasks, but it was pretty brutal
1
u/Shep_Alderson Nov 02 '26
There is no “hard” way to enforce agents.md rules. They should only be considered suggestions. If you need hard enforcement, that requires a non-agent control outside the agent’s session.
Model switching is generally controlled by things like subagent definitions or what you tell it, but is also still not guaranteed.
Your best bet for reducing the scope of a review is to use git shas for a start and end target encapsulating the slice. Anything looser than that cannot be guaranteed, and even that’s not bullet proof. It’s not always the best option either. Sometimes you make changes in say, one PR, but those changes interact with code outside the diff. Reviewing that interaction is good. One side note: you mentioned “dirty workspace”. Do you mean this as in you have a lot of unrelated code changes in a git repo that are just sitting there unstaged? Or do you mean your codebase is a mess and it’s going off trying to solve issues it finds during reviews of connected code?
There is no way to enforce a hard stop within the prompt call/response itself. The agent has no concept of time nor usage while processing and responding to a prompt. The best it could do is perform a tool call after it finishes processing the prompt to check usage, but that would be after the usage is consumed. If you need this strictly, you will need to rely on an external tool, though usage reporting seems to lag by many seconds or even minutes, so that still won’t be perfect. There’s a lot of usage related to thinking that you have no visibility into outside of the usage report from the OpenAI API. Best you can do is have an external program watch the usage report and then maybe have a way to send a hard stop request to the harness, but that’s probably not going to go well for you. You’ll probably end up with a lot of partially completed responses and potentially tool calls going haywire.