Evaluating Long Range Dependency Handling in Code Generation LLMs
Yannick Assogba, Donghao Ren · 2025 · 7 citationsRead the paper
As language models support larger and larger context sizes, evaluating their ability to make effective use of that context becomes increasingly important. We analyze the ability of several code generation models to handle long range dependencies using a suite of multi-step key retrieval tasks in context windows up to 8k tokens in length. The tasks progressively increase in difficulty and allow more nuanced evaluation of model capabilities than tests like the popular needle-in-the-haystack test. We find that performance degrades significantly for many models (up to 2x) when a function references another function that is defined later in the prompt. We also observe that models that use sliding window attention mechanisms have difficulty handling references further than the size of a single window. We perform simple prompt modifications using call graph information to improve multi-step retrieval performance up to 3x. Our analysis highlights ways that long-context performance needs deeper consideration beyond retrieval of single facts within a document.
What the full text shows
Shown in the lab- Performance degrades significantly when a function references another function defined later in the prompt (forward references). — up to 2x degradation (Multi-step key retrieval tasks)
- Adding call-graph information as comments in the prompt improves multi-step retrieval performance. — up to 3x improvement (Multi-step retrieval tasks)
- Models using sliding window attention show a large performance drop when the distance between relevant snippets exceeds the window size. — significant drop moving from 4k to 8k context (Mistral 7B v0.1 and StarCoder2 7B)
- Call-graph comments specifically improved the three-step retrieval and concatenation tasks. — 1.6x improvement for three-step; 1.5x for concatenation (Aggregated across models)
- Incorrect responses often consist of return values from distractor functions. — 10% of all responses; 20% of incorrect responses (1 and 5 distractor conditions)
- Setup
- Context windows up to 8k tokens; models tested include Mistral 7B v0.1, StarCoder2 7B, StarCoderBase (1B, 7B, 15.5B), DeepSeekCoder 6.7B base, GPT-4o mini, and GPT-4o.
- How
- The researchers used synthetic multi-step key retrieval tasks (one-step, two-step, three-step, and concatenation) to test LLMs. They evaluated the impact of context length, distractor functions, function ordering, and the addition of call-graph annotations in prompts.
- Limitations
- Used synthetically generated functions rather than real-world code. · Did not test complex structures like recursion, branching control flow, or helper function reuse. · Randomly generated function names may be out-of-domain compared to natural codebases. · Evaluated only decoder-only causal transformers.
Summarized by Gemma 4 from the open-access full text · 26 Nov 2026. Read it