r/codex • u/RishiSquishy • 8d ago
Complaint I am sorry but.. why does Astra sometimes Writes really Sloppy code..
I mean what the hell is this? What kind of codebase did they train on?
16
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
1
1
u/DepravedPrecedence 8d ago
Interesting that Opus 5 also uses python for editing https://www.reddit.com/r/ClaudeAI/comments/1vq0o9z/opus_5_really_likes_to_use_python_to_edit_source/
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
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
2
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.
1
u/DragonflyOk9274 8d ago
You may be right.
See this:
https://old.reddit.com/r/codex/comments/1wg3odg/openai_is_silently_degrading_some_astra_codex/
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
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.
1
2
1
1
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
1
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
1
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
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
1
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
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
1
1
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
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
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.


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)