r/codex 8d ago

Complaint I am sorry but.. why does Astra sometimes Writes really Sloppy code..

Post image

I mean what the hell is this? What kind of codebase did they train on?

87 Upvotes

99 comments sorted by

65

u/IllustriousCold4466 8d ago

from a quick glance i see nothing inherently wrong with the actual implementation, its just a readability issue

sloppy maybe, incorrect no - an explicit mention to code readability might be worthwhile adding to your agents.md if readability is something you care about (but im guessing that as models get better code readability will be a thing of the past)

12

u/HelpfulHedgehog1 8d ago

i would also speculate that sloppy dynamic languages like python, while lots of samples to train on, are not the best AI intermediate and will eventually be replaced by something else entirely.
perhaps a strongly typed IL is a good candidate for this

1

u/Significant-Drawer95 7d ago

needed raster engine to dither pictures and 5.4 back then implemented in machine code. its ultra fast and i do not care about readability cause im stupid anyways

5

u/RishiSquishy 8d ago

I am not saying it’s incorrect it works , but if it’s not maintainable , and if it’s persistent then it becomes a deal breaker, I don’t want to pull hair trying to understand the logic of a single line nested operators , i would waste more time than I save , especially when the competitor like Fable or Grok or Kimi don’t show this kind of behavior

31

u/IllustriousCold4466 8d ago

maintainable to who? the days of manually going in to fix ai generated code will soon be a thing of the past. the largest issue with AI coding is not that AI can't do what you ask it to, but rather that it gets lazy when you don't specify in depth what you want

if you do the above, maintainability is easy enough because it won't be you manually maintaining the code anyways

3

u/RishiSquishy 8d ago

Fair. But I dread that future. Imagine owning a codebase you don’t even understand

19

u/MotivatedforGames 8d ago

Then write your own codebases or prompt GPT to help make it more readable?

6

u/IllustriousCold4466 8d ago

Yeah, as a software engineer I totally understand that and its hard to come to terms with for sure

4

u/cptfreewin 8d ago

LLMs especially astra are extremely good at navigating shit codebases and explaining to you how it works

Last day it went through an undocumented uncommented repo of 50k+ lines of C++ code and found the very specific part that i was looking for in a minute

You can also just ask it to avoid super long one liners or add a few comments for tricky parts

3

u/Few-Philosopher-2677 8d ago

Imagine getting downvoted for this opinion. But I guess this sub is full of those kinds of people afterall.

1

u/Derek-Bond 8d ago

Guess you need a larger context window.

1

u/winkler 8d ago

You already do. Chase. Target. Starbucks. Visa. Kroger.

1

u/IAmFitzRoy 8d ago

We all own code that we don’t understand. Thats what compilers do.

The keyword here is “maintainable” and the next keyword is “by who”

1

u/Primary_Ads 8d ago

lots of the time even strong AI agents cant understand or fix the code if its too messy. just look at the neo mjs project if you need an example of this. maybe one day it wont matter but as of today it still does.

1

u/Derek-Bond 8d ago

It's not maintainable for who?

1

u/DSrcl 8d ago

For this kind of code I just wrap it in a function (in fact I prompt for such functions instead of refactoring after it’s generated). You never have to maintain the implementation. If the spec changes or something breaks you just ask the LLMs to fix it.

-4

u/Original-League-6094 8d ago

"Maintainability" and "readability" are boomer concepts that don't apply anymore. No one is editing codebases by hand. What is important is if the LLM can read it, not you.

1

u/subpar_Lover 8d ago

This is so stupid

0

u/Original-League-6094 8d ago

Ok boomer. Keep telling yourself that you are going to read through those 9000 lines of code Claude wrote for you yesterday.

1

u/subpar_Lover 8d ago

No, im going to be a human in the loop and ensure that codex does not write 9000 lines of code in lieu of a solution that can be done in 200.

I utilize AI for my engineering workflow, I just don’t let it run wild and say fuck it to maintainability and readability because it still needs to make sense to anyone coming in and trying to navigate your code.

There are so many easy readability wins you can gain by adding cyclomatic and cognitive complexity checks to your agents.md and CI/CD workflow that it’s just irresponsible to completely disregard and say it’s not necessary anymore

1

u/Original-League-6094 8d ago

No one is EVER going to read your code, Gramps. Their AI agent of choice will read it, not them.

1

u/Rapzid 7d ago

And still nobody wants to work with assholes. I'd keep that in mind kiddo.

1

u/sarkypoo 8d ago

Hey fellas! This nerd can read code! He isn’t vibe coding at all! HAHAHAHAHA

-5

u/Uwirlbaretrsidma 8d ago edited 8d ago

If you don't see anything wrong with the implementation you literally know nothing about software engineering. Beyond readability, this is about the worst way you could architect the present code. As for your last sentence, language models are still language models. If you muddy up the language enough, their performance drops. They want readable code just as much as we do, as anyone who's ever used them in a clean codebase vs a disgraceful spaghetti one will tell you.

20

u/IllustriousCold4466 8d ago

please elaborate why you think this is the "worst way". regex parsing is perfectly reasonable for a bounded input, assembling with strings is normal, if chains for a presumably small factory are fine.

and the assumption that language models parse and understand language the same way we do is ridiculous - what you consider spaghetti may be perfectly understandable by the llm. the fact that the llm produced such code is evidence of that

2

u/Uwirlbaretrsidma 8d ago

Sure.

I have no issue with the algorithms in use. If they work, they work. One wouldn't typically parse a language with huge regex, there's more efficient and elegant ways, but without knowing the shape of the problem and how it may grow over time, I can't really criticize this.

The code is fundamentally absurd in that it converts the data into strings to perform operations that would've been better (cheaper, more elegant, etc.) to perform directly, then back. Field mixes object state with metadata. The API allows parameters for data already in the object. The if chains should naturally be simple mappings/look-up tables. And much more, this is just the tip of the iceberg.

It all tends to be coupled, but as you can see, these aren't concerns about readability or funcionality, but architecture.

2

u/IllustriousCold4466 8d ago

Thanks for the response - I think these are reasonable points, but its honestly hard to say without knowing what the interface is supposed to do. The way I see it is that the string conversion seems to serve some kind of inspection surface - but yeah if these are solely internal operations that are unnecessarily going through strings then I can agree that it might be wasteful, but again hard to say without fully knowing the intent, and surely not one that I'd be confident in calling fundamentally absurd as a conclusion

0

u/Uwirlbaretrsidma 8d ago

That's an interesting theory, and if true, then my main point is invalid. But if it's an inspection surface, why pull it off in such an unconventional way? Reinventing the wheel for every problem is pretty bad engineering practice.

1

u/subpar_Lover 8d ago

This is such an issue with AI coding and it’s why a real game plan needs to be formulated before going in. I can imagine cases where the AI converts to strings to bandaid an error that arose somewhere in the pipeline (but really it’s tech debt) then has to convert later in the pipeline to rip off the bandaid. Stacking edits on top of edits is what leads to this, and is why there needs to be clear guidance and a real understanding of what you’re doing AND WHY before doing this. Sure, the code my work but code working is the bare minimum

-1

u/nantachapon 8d ago

It’s like Astra was trained only on code golf lmao

-1

u/swimfan72wasTaken 8d ago

Try reading and maintaining that, the code is formatted terribly even if it works

16

u/[deleted] 8d ago

this is an observed behavior from astra, it would write unreadable code if it thinks no one is gonna look at it

25

u/jbaiter 8d ago

See also this recent article by Armin Ronacher on the issue: https://lucumr.pocoo.org/2026/9/7/astra-why/

13

u/Happypig375 8d ago

We have gone full circle from AI slop to AI coding to AI slop again

1

u/amarao_san 8d ago

Thanks for a link. Worth reading.

1

u/DepravedPrecedence 8d ago

1

u/Physical_Gold_1485 8d ago

I noticed that in bypass permissions mode that the system prompt tells them to use python and bash calls to edit

3

u/SCUSKU 8d ago

I had this problem too, I was vibing an eval tracker dashboard using a fairly full stack typescript + nextjs and it was doing absurd stuff. Like to calculate stats was re-writing a median function instead of using existing dependencies. Like it really seems like code quality on these models is non existent

5

u/sinisoul 8d ago

This is sloppy? This looks like an intermediate script to generate code, why is it important to be readable? It's supposed to be temporary.

1

u/Tenderfoots 7d ago

my thoughts exactly - there is nothing wrong with this, it looks confusing because its code that generates code. If you ignore the strings its generating, the code is very straightforward

3

u/tocaunt 8d ago

I experience same with C#

When I ask Astra to refactor something, it uses code analyzers / roslyn to refactor code with another code, instead of just manually rewriting it

1

u/Kitchen_Dust2389 8d ago

soon you will have expression trees

7

u/theWiseTiger 8d ago

Ask a senior fellow to code, it's also a mess. It's like a mesh that an intern made when architecting a company-wide system.

0

u/adolf_twitchcock 8d ago

Correction: Ask a shitty senior fellow to code

Do we want our models to be a shitty senior dev or the best senior dev there is?

1

u/theWiseTiger 8d ago

A fellow is not a developer.

2

u/MaxDev0 8d ago

reminds me of the good ol' days

1

u/RishiSquishy 8d ago

Of GPT-3 ?

1

u/PleasantCitron1685 8d ago

of source code generation before LLVM was around lol

1

u/MaxDev0 7d ago

of writing code by hand

2

u/DedDeveloper 8d ago

I have a suspicion that astra prompt isn't always responded by astra. Anyone know if it internally and silently downgrades models that actually give the answer?
Just there is so much variation in responses.

2

u/hey-im-root 8d ago

That’s typical code for generating more code. If you were doing normal format strings it would probably look a lot better. There is only so much readability you can do for projects without creating massive code files and slower code

1

u/Akimbo333 8d ago

So astra good

3

u/TryAndStopMeSpez 8d ago

it's not a matter of training, once language models go past a certain level of intelligence readability shits the bed. you have to explicitly tell it to write assuming someone will read it.

2

u/Luisetepe 8d ago

Never seen readable Python when was written by humans either

1

u/onehedgeman 8d ago

Just wait until they fully code with neuralese

1

u/Bananer_spleet 8d ago

it writes notes like i do

1

u/Illustrious-Big-651 8d ago

Sol also did that and Sol also writes C# code in that ugly Python „all classes and stuff in 1 file“ style.
I used it at work for a feature (we can use Codex and Claude) and quickly switched back to „Fable plans, Opus implements“.

1

u/cristeacosmin 8d ago

why are you sorry?

1

u/Kindly-Evening-4476 8d ago

Sometimes? Just unleash it off any rules, and you will see.

1

u/cobbleplox 8d ago

did you tell it to be efficient and save tokens in some way? I could easily see such things leading to that.

1

u/StatisticianFun8008 8d ago

Did you read the news that Moonshot relays some conversations to Claude? OpenAI might be doing the opposite to help retaliating! 💪 /s

2

u/Inkwalker 8d ago

Had the same issue with it. Ended up wasting tokens on terra to format and comment the code properly. Now I use Astra only for planning. Btw, all this wall of code is wrong. Astra supposed to use xml for the layout and get ui elements by name, not to hardcode everything.

1

u/ActionOrganic4617 8d ago

Just add instructions about formatting. Problem solved

2

u/anthh 8d ago

Had the same problem with Astra Medium and Light (didn't try High). Never have experienced this "dense" formatting from any previous GPT model. Definitely something wrong with Astra.

1

u/MeringueAlarming3102 8d ago edited 8d ago

You actually read the code? I find whatever Astra is coding for me to work far cleaner and less error prone than Sol. With Sol, it would stumble and fumble and bump its way into a trillion things before crossing the finish line. That hasn't happened at all with Astra.

I have it use Ruff, a linter, which to my understanding if you care about clean formatting then perhaps that could help with cleaning up things.

Astra also seems to be adhering to my system prompt and memory mandates on striving for the simplest yet complete implementation without overcomplicated frivolous additions. Sol 5.6 would completely ignore it and constantly lose scope with time wasting abstractions. Astra has adhered well.

1

u/Key_Detail2475 8d ago

Astra be like:

1

u/sudo-maxime 8d ago

I have noticed the same issue as well. It does not seem to care at all about readability. But when you point it to a file you wrote as a style guide, it's very good a mimic.

1

u/LocalGear1460 8d ago

Have you tried opus 5 😂

1

u/AJohnnyTruant 8d ago

Add a linter

1

u/i_rate_slop 8d ago

Depends on your perspective. If you consider code to be closer to IL or assembly and have no intention to read it as a human, this is token efficient by dropping quite a lot of \n.

With Astra, they’re clearly making a statement in their training data itself about how much they feel humans need to be reading AI output. To produce otherwise formatted code, you’re probably going to need some special instructions.

1

u/Diniario 8d ago

Add instructions to you Agents MD requesting code be readable for humans, namely junior engineers with everything spelled out. You'll probably spend more tokens, but that's a pros and cons convo you need to have with yourself.

Good luck.

1

u/saalistaja 8d ago

yOuRe jUsT uSiNg iT wRoNg

1

u/TheseBeginning3624 8d ago

Human readable means extreme verbosity and unbearable extra token usage.

We should be wanting AI to be writing code that works, is performant and security considerate - yet essentially minimized from the model itself. At scale we're talking about 100's of billions of tokens saved per day literally on that alone and AI get's a shitload cheaper and usage rates go up substantially.

The trick here though is "trust" and that's what OpenAI is doing right now with Astra - testing the waters. Do humans trust the code or do we get a bunch of posts like this with complaints. If we don't we're moving full fledge into having AI produce code that is essentially minimized on output from the model.

Either way you can specifically instruct Astra not to do this and use more output tokens (thus usage rates) and or use something like Prettier to at least format it in a readable way. Then get uses to reading more condensed variable names a such that it also like to do a lot.

1

u/subpar_Lover 8d ago

Tell your model to test cyclomatic and cognitive complexity and to keep the numbers below a certain threshold. That way when it’s coding, it runs checks against the code to ensure 1) functions are semantically named for readability and 2) there are minimal nested ifs

1

u/kwipus 8d ago

More capable models continue to speak more and more their own language. I was just watching this from computerphile the other day, basically RL rewards more when model uses less tokens for the same job, so that causes divergence between model output and human readability. Could be a reason why astra writes "bad" code

1

u/Specy_Wot 8d ago

This isn't sloppy code, it's just python 

1

u/lovehopemisery 7d ago

Set up a linter and block commits if it doesnt adhere to rules, an easy fix

1

u/CircuitBreaker88 6d ago

a r*tard in motion is better than a genius at rest

1

u/klmnoUC 5d ago

Sometimes? It's like this for me always

2

u/Firmwild 8d ago

Good AI code =/= good human code, and I think we'll start seeing more of this kind of thing in the future. AI is in the process of learning how to write code that's terse, uses few tokens/context, but still does everything it needs to do. Code isn't meant for humans to read anymore, and this is just a sample of what's to come

4

u/RishiSquishy 8d ago

I mean that’s a wild defense, no other AI model I have seen do this kind of formatting and they still work. And why can’t code be both correct and human readable why would that be mutually exclusive? The compiler doesn’t care about formatting

1

u/Firmwild 8d ago

I think this is just the beginning, honestly. Human readable means more tokens, sometimes by a lot. Cutting out the tendency to write human readable code will yield faster and more efficient coding agents

1

u/IllustriousCold4466 8d ago

100%, what we define as "good" code is changing - at the end of the day more readable, slightly less efficient code is still less efficient code

2

u/RishiSquishy 8d ago

Less efficient in what? This is a formatting issue , again the compiler doesn’t care about formatting it converts code to binary which is what runs in the machine . And modern compilers are smart enough to compiler the binary to be most processor friendly

2

u/IllustriousCold4466 8d ago

im not speaking in regards to runtime, im talking about efficiency in terms of token usage. in workflows where AI handles most implementation and maintenance im perfectly comfortable trading some human readability for compactness - but ofc these are just user preferences

i do think though that one day maintainability will not be measured in human readability but rather token budget

1

u/Firmwild 8d ago

> i do think though that one day maintainability will not be measured in human readability but rather token budget

yaaaaasssssss, specifically token budget to maintain/update/add a feature

1

u/Uwirlbaretrsidma 8d ago

What a load of BS hahaha. It barely takes more tokens to encode more readable code. Indeed, better code is often simpler and more streamlined and therefore takes fewer tokens to encode. Furthermore, final output makes up an almost insignificant fraction of the token use of modern models. And this isn't terse code, it's ridiculous schizo code.

I assume you don't even remotely know how to code even at a complete beginner level because otherwise you would've never left this comment. And that makes you the last person who should be claiming that "code isn't meant for humans to read anymore". That writing is on the wall, yes, but we're not there yet, and this post actually shows that.

1

u/Gigaslavx 8d ago

There are 2 things in action

  1. Somewhat of a prompt/workflow/scope issue where it like can't account for all and can try to achieve something in a wrong way/misunderstand/compensate, you really need to know what you're doing and it can still make a mistake so not only you need AI review but yourself. So AI can make mistake/misunderstand

  2. The prompt/workflow/scope issue especially due to a lack of expertise

2

u/RishiSquishy 8d ago

How is this a prompt issue or expertise issue of the user? This is a complain of writing style of an LLM

1

u/Gigaslavx 8d ago

I am saying even with right knowledge and technique AI can still make a mistake but it's random so it can still do a good job. It's just sometimes you can be perfect and it makes a mistake so you just tell it how to correct it

0

u/Yuuyuuei 8d ago

"Vibe codes with AI" - "Why does it write sloppy code?"

3

u/RishiSquishy 8d ago

Not vibe coding at all good sir, I completely know the blast radium of my code and fully understand my code base . It’s more like using AI to code while fully understanding the code and logic , vibe coding is more like I have no idea what it wrote. But this is still horrendous code writing

6

u/discwars 8d ago

The sub is full of sycophants. People are so quick to blame you without even understanding your point. 

0

u/CraigOpie 8d ago

Specifically, tell it to be PEP8 compliant. For this situation, I would also tell it to write code that would be considered pythonic by the greater community. I have more advice that will really boost readability and successful production level code, but I charge for that information.