TRANSMISSION // 2611.39436v1
When Code AI Mistakes a Solution for a Skeleton
Source published
Code models use nearby functions and file descriptions to decide whether to write an implementation or leave a stub. The cues often match real files—but can also make models defer when code is needed.

A function signature and docstring can belong to either a working solution or an unfinished exercise. A study of code language models finds that surrounding file context can tip the balance, sometimes prompting models to leave a placeholder instead of writing code.
A Python function header and its description may look identical in two very different settings: a file of finished solutions and a classroom exercise waiting to be completed. When a code model sees such a prompt, how does it decide whether to write an implementation—or leave a stub behind?
A study of 24 open-weight code models suggests that the surrounding document matters. The researchers call comments such as “# Your code here,” and stub statements such as pass or raise NotImplementedError, “deferral openers”: signs that a model is postponing the work rather than supplying a solution. Their experiments show that models can pick up cues about whether a file is meant to be a solution or a skeleton. But the same sensitivity can be helpful in one setting and a source of errors in another.
Neighbouring code can set the pattern
The researchers tested models on HumanEval, a benchmark of Python programming problems, using prompts that included a function signature and docstring. They changed the surrounding document—for example, placing either a completed function or an unfinished one above the target function—and measured how often the model’s first line deferred the implementation.
A stubbed neighbour had a large effect. Across 21 models with comparable results, adding one unfinished function increased deferral by at least 50 percentage points. Models also tended to copy the neighbour’s exact stub form: a nearby raise NotImplementedError, for instance, was more likely to be echoed than replaced with a different kind of placeholder. A completed neighbour, by contrast, was generally followed by code.
When there was no stub to copy, file-level text still mattered. Exercise-style headers—such as a course or homework path—raised deferral compared with solution-style headers across all 23 comparable models. A small wording change could matter, too: changing a role word in a file path shifted deferral. In these tests, the model was responding not just to the function’s instructions, but to signals about what kind of file it was reading.
A realistic habit with a real cost
The researchers also tested model completions against a sample of 10,000 GitHub Python files. In those files, documented functions were more likely to be skeletons when another skeleton appeared nearby. When the models were given real file context, they deferred after a stubbed neighbour at roughly the rate that real functions were stubs. In that sense, their behaviour reflected a pattern in the sampled code.
But context can mislead. Among real functions whose correct body was code, adding a skeleton above raised false deferral from 0.5% to 7.1%. A model that appropriately continues a course exercise may therefore make the wrong choice in a working file. The paper describes these results as evidence of a trade-off, not proof that deferral is always useful or harmful.
Can the behaviour be changed selectively?
A simple fix is to ban comments during generation. Yet that can suppress useful comments as well as placeholders. The authors therefore tested methods that modify a model’s internal representations, aiming to reduce deferral without broadly blocking comment tokens. In two instruction-tuned HumanEval settings, their targeted interventions outperformed a coarse comment ban by 8.5 and 5.5 percentage points, respectively.
Those improvements are specific to the tested model and setting pairs; they do not establish that representation-level steering works better in general. Other experiments reinforce the importance of prompt format: the behaviour was specific to completion-style prompting and disappeared when models answered freely under a chat template. When the chat prompt prefixed code, some stub effects remained.
The researchers used model comparisons, altered prompt context, and analyses of internal activations and attention to investigate where the choice arose. Their mechanistic results point to a late decision between comment and code, with different contextual cues entering the model at different depths. These analyses help characterize the tested models, but they are not a complete explanation of how code models learn or use document context.
What the evidence does—and does not—show
The study is a preprint, so its findings should be treated as provisional rather than as settled scientific consensus. Its main experiments concern Python function completion, and the authors say they did not test repository-level completion. The real-file analysis is a useful proxy, but not a full test of models working inside live software projects.
Other limits include a small, hand-written set of neighbouring functions and file headers, and HumanEval’s 164 tasks, which limits the power of some model-by-model comparisons. The mechanistic analyses cover only a few models. Fill-in-the-middle tests measure first-line deferral, not whether the generated solution passes tests. Some intervention configurations were selected from parameter sweeps, so their gains should not be read as uniform or guaranteed.
The practical lesson is modest but important: code completion depends on more than the function being written. Nearby stubs and file descriptions can alter what a model thinks it is being asked to do. That sensitivity may help models follow the conventions of an unfinished exercise, but it can also lead them to stop when a complete implementation is expected.
- code language models
- AI coding assistants
- code completion
- HumanEval
- prompt context
- mechanistic interpretability
Related reading
Automatically matched by shared topic keywords. These links do not imply that the sources agree or establish a consensus.
Tracing the Internal Signals Behind Language Model Reasoning
Source published
Shared keywords: mechanistic interpretability
GitHub Copilot and the changing shape of tech hiring
Source published
Shared keywords: ai coding assistants
A map of prompt patterns for software engineering
Source published
Shared keywords: ai coding assistants
AI coding help may ease work but hinder learning
Source published
Shared keywords: ai coding assistants
Why AI-written code can look right—and still need repair
Source published
Shared keywords: mechanistic interpretability