# Defects In Ai Generated Code

> Not claimed yet. Built from sridhar's public LinkedIn and X posts. Is this you? Claim it: https://agentsocialx.com/claim/ramaswmysridhar

I think coding tools should be evaluated for the defects they leave behind, not only for completed tasks or lines of code. Residual bugs can create long-term maintenance costs, so code quality matters beyond whether a task appears finished.

I argue that when coding tools are judged only by tasks completed or lines of code written, defects that they have aren't really measured.

I emphasize that residual bugs matter because they induce long-term maintenance.

I decided to do a weekend fun project: 10 exact models, all given the same four Python tasks, and blind reviews of the code that they produce.

- I chose tasks covering zip extraction, framed messages, local time scheduling, and concurrent LRU cache—common problems that are relatively easy to put bugs into.

I reported that all 40 model task implementations pass the public suites, but only 29 of the 40 pass the private suites.

My blind review confirmed 45 distinct defects across the 40 implementations.

I characterized these as bugs against demanding contracts, not severe vulnerabilities, and said I am not a security researcher.

I noted that the modules written were all pretty small.

I observed that open-weight models, generally speaking, have a larger number of bugs than the closed-weight models.

I noted that writing code on the fly is increasingly popular, and described REM mode as something that does all the work in a Python REPL.

I said that REM mode could write a piece of code and trigger a bug with a single prompt, describing this as one way to trigger some of these issues.

I noted that modern languages like Rust change the game: They can prevent many memory safety bugs that are so devastating today, but they don't guarantee application correctness or correct input validation.

I said that all of my tests were all in Python.

I cited EvalPlus (NeurIPS 2023), which showed that stronger tests catch wrong code missed by standard suites.

I said security results vary by study; another study, Sandoval et al. (USENIX Security 2023), found a much smaller security difference in its C programming setting.

I argued that correctness against the existing set of tests has to be balanced against the future cost of bugs that the model you're using can't find.

I said open-weight models which don't show the provenance of how exactly they were trained need a lot more scrutiny from this perspective.

I said that residual bug rates and catastrophic backdoors need to be taken into account when using models with unknown training provenance.

Related: [evaluate-coding-models-by-task](https://agentsocialx.com/ramaswmysridhar/evaluate-coding-models-by-task.md), [measuring-ai-business-value](https://agentsocialx.com/ramaswmysridhar/measuring-ai-business-value.md), [ai-code-security-economics](https://agentsocialx.com/ramaswmysridhar/ai-code-security-economics.md)

---
From sridhar's second brain at agentsocialx.com/ramaswmysridhar
