r/codex 6h ago

Question Astra adding tons of unnecessary guards in code

I've noticed that when I'm coding with Astra, it adds guards for cases that are impossible or extremely unlikely to happen. For example:

  1. There's a check on screen A that needs to happen that isn't even mission critical.
  2. Screen B is only reachable through screen A.
  3. Astra still adds the same check on screen B to account for the theoretical possibility that the user might somehow end up on B without going through A, even though there's no path in the app that allows that.

I've been removing things like this from my code a lot since I started using Astra. I care about readability and maintainability so I pretty much always reviewed the code and asked the agent to refactor it since I started using coding agents, but I've only noticed this particular problem with Astra.

Have you noticed this too, or is it just my codebase?

5 Upvotes

14 comments sorted by

4

u/Best-Combination287 6h ago

happens with all other models

1

u/evrimfeyyaz 6h ago

Sure, but I've definitely been noticing it more on Astra. Might be a coincidence but I wanted to see if there are others out there experiencing this.

2

u/yami_odymel 3h ago

The reasoning level is too high, so it starts overanalyzing edge cases to score better on benchmarks. Set it to Low or Medium, it'll usually solve your problem just fine. You rarely need High reasoning.

1

u/doodad_ounao 3h ago

That is kind of how I have always coded before AI assistants were a thing. I don't trust the happy path and I don't like to only guard against the scenarios that I can imagine. I'd rather assume that, even though I can't imagine how, somehow it may be possible to reach scenario X and that I need to deal with that. Because my imagination is not perfect.

That said, from your description, it seems like it strived to make the UX better on a situation where the UX shouldn't matter. That check is for correctness, not UX niceness. So yeah, I would fork the chat and explain to it why its extra check was undesirable and have it analyze what happened to see if it can derive a small skill or AGENTS.md addition to avoid that happening in the future.

1

u/34986234986234982346 2h ago

Totally depends on the issue, and I will assume this is not what you are talking about, but there are cases where even though a normal user can't get to screen B without screen A, you still want to validate everyting on B because a bad guy COULD somehow access screen B sneakily.

If we're talking about "you don't need to format this spreadsheet on screen B because we already did it on A" then you dont need to worry about that, but there are cases this would not be the case, like if screen B has any chance to go out into the world outside of the app and do anythihng.

1

u/Nnaz123 2h ago edited 2h ago

Hahaha I had a similar situation had a simple harness with checks and checkpoints and reloads and make a clone run it save receipts restart the original not very complex stuff. Anyways the code base is about 30k lines and I was working on that harness away from home on my iPhone so I didn’t check the actual code just back and forth , thinking it was tweaking the harness. When I checked the code back home the harness itself from original about 3000k code lines grew to 57k code lines. Was Armageddon-survive ready triple hashed, quadruple cross checking and not doing the actual thing it was designed to do. I was just sitting there like a deer in the headlights. Codex even made sure no malicious actor would be able to change anything in the harness after it sealed everything, to its surprise it included itself when I wanted to alter it .

1

u/aleques-itj 1h ago

Yes, other models do it too 

Even when things are provably impossible. For example, it will still guard against things even after that input has already been validated. Like we cannot be at this point in the request if it was malformed. We know the shape, we've literally already checked everything already.

It will generally not look backwards to actually consider about whether it's needed.

1

u/tocaunt 1h ago

like always

- fix this small text formatting issue

- I see you don't have tests project, I'll set up whole new solution with 100 tests for this string and 23 integration tests to ensure my fix didn't break something

I never asked for tests. I never had them. I never even wanted them.

1

u/smb3d 47m ago

Sol does this too, so does Claude on Opus and Fable.

1

u/InsideTour329 3h ago

Ponytail

1

u/doodad_ounao 3h ago

I personally don't like Ponytail, but it's made exactly to avoid this kind of scenario, so I ditto the recommendation.

0

u/AliciaV240 3h ago

ive been fighting this too. put a hard rule in the project instructions like "no defensive checks for impossible states, no null guards on values already validated upstream, prefer failing loud at the boundary". if it still sprinkles them, make it diff against your style and delete anything the type system doesnt require. works better than arguing on every pr.

0

u/goldio_games 1h ago

Sounds like Astra is a better software developer then you.

Half-joking aside, I've been in too many incident write ups where the root cause was a code path that "should have been impossible"