A lot of research into LLM code generation focuses on one fairly simple question: does the generated code work?
And that makes sense! Functional correctness is hugely important, and benchmarks that measure whether generated code passes a set of tests have been incredibly useful for tracking the progress of coding models.
But as someone who spent several years working as a software engineer before starting my PhD, I’ve always felt that there’s quite a lot more to good code than simply passing tests.
Does the model choose an appropriate programming language? Does it use existing libraries sensibly? Does it introduce unnecessary dependencies, or even invent ones that don’t exist?
These are all things that matter in real software development, but aren’t necessarily captured by traditional code generation benchmarks.
Over the past couple of years, quite a lot of my research has ended up exploring different parts of this problem. So I thought I’d bring some of it together in one place!
Choosing the right tools for the job
One of the first things I became interested in was how LLMs choose programming languages and libraries when they’re given some freedom.
In our ACL 2026 Findings paper, we found that models have some surprisingly strong preferences. They tend to favour familiar libraries, even when they’re unnecessary, and have a particularly strong preference for Python, even for projects where other languages might be much better suited.
We followed this up with LangChoiceBench (EACL 2027), a benchmark specifically designed to evaluate programming-language choices. Across 25 models, we found that Python remains heavily over-selected, and that models often recommend one language before implementing their solution in another!
We also looked at why models make these choices, finding that they often default to Python without really considering the requirements. Occasionally, they even invent evidence to justify choosing Python, a behaviour we call phantom evidence.
The interesting point here is that a model can generate perfectly functional code, but still make a poor decision about which technologies to use in the first place.
When libraries don’t exist
Another area I’ve been investigating is library hallucinations.
LLMs sometimes generate code that imports libraries or calls functions that simply don’t exist. This is obviously a problem for correctness, but it’s also an interesting reliability and security issue, particularly when developers trust generated code without checking its dependencies.
In our EMNLP 2026 paper, we investigated how realistic variations in developer prompts affect these hallucinations.
We found that seemingly small changes, such as misspelling a library name or asking for functionality from a particular year, can dramatically increase hallucination rates. We also introduced LibHalluBench, a benchmark for evaluating these behaviours systematically.
For me, this highlights another limitation of evaluating models on fixed coding tasks. It’s not just whether a model can produce working code, but whether it does so reliably when users phrase their requests in slightly different ways.
What happens in real coding agents?
Of course, most of these experiments involve prompting an LLM directly. But increasingly, developers are using coding agents that can inspect repositories, edit files, and interact with development tools.
So how does library usage change in these more realistic environments?
In our MSR 2026 paper, we analysed 26,760 agent-authored pull requests to understand how agents use external libraries.
We found that agents frequently import libraries, but rarely introduce new dependencies. Interestingly, they also use a much wider variety of libraries than we’d seen in earlier studies of standalone LLMs.
It’s a useful reminder that model behaviour doesn’t necessarily translate directly into agent behaviour. The surrounding tools, repository context, and development workflow can all make a difference.
When reasoning gets in the way
More recently, I’ve also been looking at how reasoning models approach code generation, and whether more reasoning is always a good thing.
In our reasoning overflow paper, we found that some smaller reasoning models can spend their entire output budget reasoning about a coding task, without ever producing any code!
This is particularly common on harder tasks, where models can get stuck in repetitive reasoning loops. We also found that controlling the reasoning budget can help reduce these failures, though how well it works varies between models.
It’s an interesting example of how more reasoning doesn’t necessarily mean better code generation. We need to consider not just whether models can solve problems, but how reliably and efficiently they reach a solution.
So why does this matter?
I think the common theme across these projects is that functional correctness is necessary, but it isn’t sufficient for evaluating LLM-generated code.
In real software development, we care about maintainability, reliability, dependencies, technology choices, and whether we can trust the tools we’re using.
As LLMs become more deeply integrated into development workflows, these aspects of code quality are only going to become more important.
A lot of my current research is about finding ways to measure these behaviours, understand where models fall short, and ultimately help build better coding systems.
And that’s really what ties these projects together: not just asking whether LLM-generated code works, but whether it’s good software engineering.
I’ll write another post about my related work on improving these behaviours through post-training soon!
