r/codex • • 23h ago

Question I'm in edge case hell. What am I doing wrong?

In the last month or two, I have found using Codex an absolute nightmare. I used to be able to just say roughly, "This is what I want at a use-case/functional requirement level... consider the following edge cases and account for them... off you go." and it would work basically every time.

Now, sessions seem to be dragging on for days as it constantly finds new edge cases to try and fix. When I stop and dig into it, the explanations I get are ludicrous, like the odds of it happening would be infinitesimally small - "Oh, if a user selects an option, then their connection drops and they background the app, and then they come back to it later and in that time the data provider has changed the primary identifier it would fail."

I can't seem to prevent it, despite prompts and instructions to:

  • "focus only on the top few edge cases"
  • "this is not enterprise-grade software - be practical in your approach to testing and edge cases."

...and things like this.

Has anyone else encountered this, and if so, how did you overcome it?

It doesn't seem to matter what model/effort I use, although it does seem to be worse when I use a /code-review loop that I built that goes through max 3 rounds of code review with other agents - Claude and Codex.

For context, I am semi-technical, have worked in tech for over a decade, but not a SWE.

27 Upvotes

36 comments sorted by

15

u/itix 22h ago

This is an architectural problem in your app design. You lack generalized failure handling mechanisms. It could be something as simple as "reset app if any problem occurs". Now you have infinite number of different error cases and it tries to account them all.

Prompts like "this is not enterprise grade software" are useless because there is no definition for enterprise grade software. In fact, they are often just bad. Instead, generalize error handling and define a list of failures that should be specially accounted for. The "top few edge cases" is vague again, like I am more critical of FAANG slop than others while somebody else is happy with any junk app they spit out.

2

u/jaysonrobinson 22h ago

Thanks. So, how do I "generalise error handling"?

1

u/DependentOnIt 9h ago

Look up out of the tar pit paper. Define your apps valid states

1

u/itix 22h ago

Prompt it. I mean, say you want simplified error handling and don't care if the user loses data or progress. Now, this can burn some tokens because AI gets relevation "he does not want my edge cases and i should purge them" so it probably purges a substantial amout of code.

I think /plan could be a good idea here.

5

u/Unhappy-Loss-97 19h ago

A 3-round Claude/Codex review loop with no stopping rules is basically an infinite edge-case factory. Both models are trained to sound thorough, so if they don't find a real bug they will happily invent a theoretical one just to avoid saying "looks fine".

Four rules snapped mine out of that spiral:

  1. No theoretical bugs allowed: the reviewer has to prove every claimed defect with an executed failing test or probe, otherwise it gets dropped.
  2. Hard cap on findings (say 5 max, ranked P1/P2/P3) so it can't pad a verdict with twelve minor "what ifs".
  3. Know when to call time: if two models are arguing over trivial edge cases by round 2 or 3, draw a line under what's agreed, merge the safe core, and fork a separate branch for the residual. Saves hours and a ridiculous amount of tokens.
  4. Overnight bug hunt - get a capable model - preferably local, on cheap electricity to keep testing even after you have merged - more edge cases still get shaken out, and you get the sleep know the most painful prt is being taken care of.

1

u/jaysonrobinson 18h ago

this is very useful, thanks

-1

u/Forward-Memory944 11h ago

That's a slop ass LLM reply. You realize that any account that flings slop on reddit is very likely using a lower end, cheap model right? It's unlikely to have very good advice.

A "3 round review loop" is only going to suck up more usage and time lmao.

2

u/jaysonrobinson 10h ago

Ok mate. Was actually just brevity but have a good day

6

u/RudyHuy 23h ago

That's what gpt added for me in ~/.codex/AGENTS.md a long while ago and so far it's been working well:

## Anti-overengineering defaults

Implement the explicit goal and ordinary supported behavior. Do not invent handling, diagnosis, recovery, repair, persisted state, protocols, or special verification for rare, corrupt, tampered, unsupported, or otherwise unwarranted conditions.

Prefer simple prevention, natural errors, or fail-fast behavior for material foreseeable failures. Do not weaken correctness in ordinary intended operation. Use existing checks, simple behavior tests, or direct inspection; new verification machinery needs explicit user authorization or an explicit project requirement, not an agent-generated plan or review suggestion.

Explicit user instructions and binding project requirements override these defaults. When stronger safeguards may be warranted by security, privacy, safety, compliance, durable data integrity, irreversible effects, or public compatibility but are not required, surface the choice instead of silently adding machinery.

Treat current-scope changes as undelivered unless the user or concrete release/deployment evidence establishes otherwise. Commits, reviews, milestones, and completion records alone do not establish delivery. Revise work in progress directly; do not create versions or compatibility/migration handling for intermediate development states or hypothetical consumers. Preserve actual delivered baselines where required.

1

u/jaysonrobinson 23h ago

thank you, I will give this a try!

2

u/GooglesExpert 23h ago

These are good defaults. I forked codex a while back just so the fork has all the anti over engineering guard rails among other things:

https://github.com/cutoken/cowdex

The first time i tried coded months back with 5.6, it spun its wheels for 24 hours and produced nothing. And hence the fork!

2

u/dranaei 23h ago

Does that save you usage?

1

u/Painwheeel 7h ago

should be criminal for vibecoders to give advice like this. i could never feel good about myself if i knowingly know nothing about what im talking about and give advice to a person's cry for help.

2

u/MaqeSweden 23h ago

Are you still using the same chat that you started working on this issue with?

It can be a good idea to have it write its shortest possible handover file and start it again with a new chat agent and explain to it before it reads the handover file what you felt the issue was - let it read the handover - and then create a plan for how to solve exactly what you want and nothing else.

Then let it set one or more sub-agents to execute on said plan and have the main chat orchestrate and keep an eye on that they are following the plan.

1

u/jaysonrobinson 23h ago

Thanks. I have tried this but it just seems to end up in the same place.

2

u/MaqeSweden 23h ago

Have you tried different models? (astra, sol) or Claude (opus, fable) or Gemini (Neon or Carbon). Explain in as much detail as possible - and have your failed agent write up as detailed report as it can - so that when other agents review the repo and the job done, they can help identify where it went wrong and why.

If this is an important problem I think it could be well worth an extra $40 for a month of claude and gemini to solve it. Probably will take less than 5% of that capacity, and gives you plenty of chances for new options.

I find that Astra, Fable and Carbon usually finds different things when reviewing difficult or important aspects of my projects.

1

u/jaysonrobinson 22h ago

Yes, it seems to be the same on Astra and Sol which are the main ones I use. I don't run into the issue on Claude Code, but I have the 5x Codex plan and only the Pro Claude plan. I don't use Gemini.

2

u/ErikaFoxelot 22h ago

Sometimes I’ve noticed that it can get hyper fixated if i try to attack the same problem over and over again. ‘Edge cases’ is vague - if you’re not defining exactly what you want it’ll interpret that as a justification to find edge cases, even those that may never have been a problem.

It’ll create problems to satisfy your request to fix problems.

1

u/jaysonrobinson 22h ago

So do you define all your edge cases and test cases manually?

1

u/ErikaFoxelot 22h ago

The ones i know about, sure. For the ones i don’t, I’ll ask specifically for an edge case audit in a separate chat, use that to gather and triage, then take those findings over and fix them like normal bug reports.

Edit: though what counts as manually these days is still a heavily augmented workflow. I don’t really do anything manually anymore.

3

u/Party-Temporary-2813 18h ago

You can do what every single tech company on the planet does and review the code and then ask for specific changes.

3

u/anime_daisuki 15h ago

you built a loop where three rounds of agents exist to find problems and you're confused that it keeps finding problems?

3

u/DanGTG 11h ago

Ask it to look at the found bugs and classify them into families, then ask it to look for a root solution for each family of bug because you feel there is likely a broad simple solution that has been overlooked.

1

u/i_reddit_it 22h ago

I had the exact same issue.

Open API really messed up with the 6.x models, no amount of prompting fixes it.

I still think Codex models are great providing you don't actually get them to do any of the implementation.

If you've not tried Claude yet, get a $20 plan and test it out, you'll soon realise it's not a skill issue.

1

u/jaysonrobinson 21h ago

Claude was my main agent until ~4 months ago and I switched to Codex because of the usage fiasco. Maybe I'll switch back...

2

u/Right-Performance-93 16h ago

asking it to consider edge cases is the job it is doing. take write access off the reviewer and let it name one check that already failed. a new case with no failing run does not get a handler.

1

u/avivng 22h ago

I'm having something similar, In my case at least it is connected to the model used though. It happens whenever sol 6.2 is used. It will just find new issues on every check made. When switching back to sol 6.1, it approves the changes and finds no issues. In my case, I am currently trying to solve that by telling the ai agent to give a score to issue it finds based on some criterias we've found online. Based on something like that, perhaps, you could tell if some findings are worth your time or not.

1

u/Swimming-Bank6567 21h ago

I've been spending a lot of time rebuilding my whole workspace, so file structures, etc. Ive then had 4 runs at getting the LLM to audi, and then rewrite documents and .MD files.

Long story short... I'm still finding massive issues, however this had led me to a funny/strange spot. Apart from a memory MD files, everything is now new, and that I've placed. But... The LLM is still finding files it deems to be authoritative, but this has been my breakthrough. I'm babysitting work, and at the first sight of a problem, and taking extra care to not complain, but ask the model why it's done something and eventually it'll tell you what it read, and why it interpreted something in the way it did; it takes a bit of prompting 😂. This is where I've then been concentrating my efforts, and step by step the whole setup is improving.

My agent server has been running since Feb, so it doesn't surprise me, after all this time, that there's all sorts of strange things it's self-made, from different models, that it thinks are current trust/direction. Even dictated project magically have things in them that I wasn't aware of.

Anywho, no idea if this helps. 6.2 is still being a durp, but I now have an idea as to why... All of this started from building a while new server to house codex/Hermes, it was dumb though at least acting a bit more "normal". Once I copied over a project, it would start falling for the same traps.

1

u/xqianliu 20h ago

I write the expected behavior and the non-goals in the issue before the run, then check the final diff against both before approving a merge. An extra edge-case handler has to point at something the issue actually asked for.

If one of those low-probability cases really matters, I add it to the acceptance criteria with a concrete test. The rest can stay out of the task, which gives the agent a clear place to stop.

1

u/ChemicalExcellent463 18h ago

Codex over-validates for me too, and what helped was refusing new safeguards unless an observed failure, a log line or a failing test called for one. Your 3-round cap limits the rounds, not how much extra stuff gets added in each one.

1

u/Tacdel0 14h ago

i'd look at the review loop first. a reviewer agent that's asked to review will always find something, so 3 rounds pretty much guarantees fresh edge cases. make it tag each finding as blocker or nice to have, with a real repro, and only send blockers back. if round one has no blockers, end the loop there.

1

u/digiorno 10h ago

Have you called it out: “it looks like you’re trying to avoid doing real work by focusing on edge cases that don’t matter? Why are you doing this? Just complete the work that I am asking of you.“

I said this to an Astra 6.2 agent that I had working on a custom interface for my TV and it basically responded with “You’re right. I can’t implement this software even though the design is technically sound, and I’ve been doing more tests on the Linux environment instead of doing what you requested.”

I had to drop down to a lower level model to actually get it to install the software. And then the lower model said “I don’t know why the other agent wouldn’t install this but this is ready to go and I’ll install it for you now.”

1

u/Last-Bluejay-4443 10h ago

Put in the caveat of “include must haves only” when it comes to edge cases

1

u/Bolizen 2h ago

Do you have that codex setting enabled that always searches for bugs

1

u/HATENAMING 1h ago

Your specific case just need a general catch for unhandled cases instead of finding every single edge case. In general from my past 2-3 days of intense usgae due to all the free reset I found that the best way to combat over engineering / thinking is to set a clear objective and a reasonable time limit. Tell it in goal that it has x hours to achieve y. GPT models follow that strictly and also has a pretty good sense of time. This pushes it to work towards more important tasks.

0

u/jim_nihilist 23h ago

This is how OpenAI makes money.

Even the most simple process gets compartmentalized into 64 steps.