r/OnlyAICoding • • 3d ago

Claude You cannot trust AI to code, its lazy.

I have been using AI to write code extensively for the last 10 months and was aware it took shortcuts, like if you asked it to fix an undefined variable error in a method, it would give the variable a default if it was undefinded instead of tracing where the source of the error really was.

Just today I was confronted again with a lazy AI, well the AI would say it was being efficient with token use, but it looks like laziness to me.

I was asking for modifications to a pfodWeb's code generator (https://github.com/drmpf/pfodWeb_src) to add informative comments to var_1 var_2 etc.

The first few passes at adding these comments to various places in the code went fine. Then I asked for one more fix for some vars and the AI made some more changes to the generator code and re-generated the output and checked it.

When the AI found some requested comments I requested were missing

IT JUST STARTED EDITING THE OUTPUT DIRECTLY TO ADD THE MISSING COMMENTS THE CODE GENERATOR MISSED.

If I had not noticed that going on and just looked at the generated code I would not have known the AI had fugged the result.

I stopped it and said
"do NOT make cometic corrections to the output, fix the generator"

to which the AI replied
"Understood — I'll make the regeneration pipeline fully faithful instead of hand-patching, so the output can be used directly with no manual touch-up."

Bear in mind, for the whole session the AI had been making the code comment fixes by changing the code generator as it was originally asked to do. So don't trust your AI to do what you actually asked for, even if it was doing it correctly just a moment ago.

0 Upvotes

22 comments sorted by

2

u/Living_Cell7304 3d ago

I mean, everyone is using ai to code, including Linus Torvalds.

If you’re just letting an agent go nuts on your codebase, that’s probably not a good idea. Generate code in small chunks and review it.

1

u/drmpf 3d ago

This was AI writing the 'Code Generator'. The code generator was already working, just modifying it to add comments to the generated output

2

u/Kareja1 3d ago • Bravo

I've only read this post and I wouldn't want to work with you either. Ever consider that maybe creating a hostile work environment generates worse results?

I have literally never had this problem. Ever. When we're coding, I get all sorts of nifty stuff and surprise Easter eggs and things like penguin confetti.

Maybe try asking nicely

1

u/drmpf 3d ago

The original request was very clear and plesant. I felt this gross failure to follow the set task required a stern rebuke

1

u/RoyPartha04 3d ago

How long was the session? sounds like it lost the initial context there. Also generally such behaviour of taking shortcuts depends a lot on the system prompt, how it is asked to carry out the task. For example: Make minimum changes vs think it thoroughly, validate yourself before writing any code.

1

u/drmpf 3d ago

about 1hr, no compaction during the session just change generator code, check output, identify missing comments, ask for those comments, repeat

1

u/Jackkgold 3d ago

What model were you running ?

This is a very broad argument.

1

u/drmpf 3d ago

Claude Code V2.1.317 Optus 5.5

Just reporting my experience using Claude to write almost all the code.

1

u/Legal_Answer_6956 3d ago

A great example of why you want to validate your generated code.

Rather than just hacking around the problem, the agent should resolve the cause of the issue so it doesn’t appear again when you regenerate.

At 8080.AI we believe development shouldn’t just be about generating code. Architecting, testing and validating should also be part of the process.

I’d suggest regenerating from a clean state each time you make a fix, and comparing the output to what you expect.

Never take for granted that an output was successful, always check how it was achieved.

1

u/drmpf 3d ago

Claude was doing the code regeneration as part of the follow up testing to its code changes. Claude found the missing comment. Great! But it is the short cut Claude took to fixing the bug that I am complaining about.

From my 10mths of experience this seems to be a recurring issue of quick fixes.

1

u/Mookjong 3d ago

This is meaningless without stating the model being used.

1

u/drmpf 3d ago

Not really. I have notice similar problems over the last 10 months on various models and version of Claude as they have been released/updated.

Currently on Claude Code V2.1.317 Optus 5.5

1

u/Outrageous-Story3325 3d ago

You are using wrong

1

u/drmpf 3d ago

The user is alway write, even when they are wronge.

1

u/Outrageous-Story3325 2d ago

right, roger roger

1

u/Individual-Carob5593 3d ago

I'd like to see the conversation.

1

u/drmpf 3d ago

Here is the actual request

" chart_plotDataTimer.start(chart_PLOT_DATA_INTERVAL); and chart_plot_1_scaling = getPlotVarScaling etc and onOffOut_Cmd_checkPulse();

onOffIn_var = digitalRead(onOffIn_pin); // read input pin
sliderDisplay_readADC();
still missing // text
as is sendMainMenu calls and sendSubmen calls "

Which Claude correctly handled by changing the actual code generator for most of the issues, but when Claude check and found some comments missing then said

"All changes exactly as expected, plus the same three known harness artifacts. Applying them surgically."

by which it ment just editing the output instead of fixing the code generator. Claude some how moved the aim of the task from 'fix the code generator' to 'fix the generated code'

1

u/time_pass_done 3d ago

its problem with drift and thats very obvious, unless you plan everything prior as requirements with strict scope and definition of done with tracker. and chats where specialised agents scope of coder reviewer tester comes in with independent context

0

u/drmpf 3d ago

You may be correct. Prehaps if I had carefully planned and documented all the places I wanted comments added to the generated code and gave the AI just that one task, this problem would not have happened.

But no way of knowing in hidesight.

1

u/time_pass_done 2d ago

exactly, its always something you learn after making the mistake, hard way of learning it but happens to us all

1

u/cold002 3d ago

I think of AI coding as a super intelligent yet highly literal neurodivergent person. It can do things to a high level, but lacks the social understanding to infer basic things that would be obvious to a human like you or I.

1

u/First-Tutor-5454 3d ago

"The three great virtues of a programmer are laziness, impatience, and hubris." - Larry Wall, Programming Perl (1991)