NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

CodeIF-Bench: Evaluating Instruction-Following Capabilities of Large Language Models in Interactive Code Generation

Peiding Wang, Li Zhang, Fang Liu, Lin Shi, Minxiao Li, Bo Shen, An FuarXiv 2025 · DOI

Abstract

While Large Language Models (LLMs) excel at single-turn code generation, real-world software development is an inherently iterative and interactive process. Existing benchmarks often fail to capture the complexities of multi-turn dialogues and repository-level contexts. We present CodeIF-Bench, a novel benchmark utilizing Verifiable Instructions (VIs)—objectively testable requirements—to evaluate LLMs in dynamic coding environments. Our findings highlight a pervasive "instruction forgetting" phenomenon: as interactions progress, models frequently violate previously satisfied constraints. We introduce the Instruction Forgetting Ratio (IFR) to quantify this decay and explore strategies to improve long-term instruction adherence.

Introduction

Traditional code generation benchmarks like HumanEval or MBPP focus on isolated, single-turn tasks. However, professional coding involves continuous refinement through feedback loops. Evaluating these interactions presents three major challenges: the complexity of multi-turn requirement evolution, the subjectivity of qualitative feedback (e.g., "make it cleaner"), and the necessity of repository-level context.

An illustration of the 'instruction forgetting' phenomenon where a model fails to maintain case-insensitivity requirements across multiple turns.

As shown in Figure 1, even when a model initially satisfies a requirement, subsequent instructions can lead it to "forget" or break earlier logic. CodeIF-Bench addresses these issues by grounding evaluations in objective, verifiable instructions that can be validated through automated unit tests.

Methodology: The CodeIF-Bench Framework

The construction of CodeIF-Bench involves a multi-stage pipeline designed to simulate realistic developer-AI interactions.

The CodeIF-Bench pipeline: from extracting verifiable instruction strategies from code reviews to data collection and session simulation.

Verifiable Instruction (VI) Strategy Extraction

The researchers developed a pipeline to identify nine objective instruction strategies by analyzing real-world code review comments. These include functional requirements like Exception Handling and Boundary Conditions, as well as non-functional standards like Annotation Coverage and Code Complexity.

Interaction Scenarios

CodeIF-Bench evaluates models across two primary interaction modes:

  1. Static Sessions: A linear sequence of predetermined instructions tests the model's ability to maintain consistency over time without external intervention.
  2. Dynamic Sessions: A feedback-driven setup where the system provides error messages or hints based on test failures, mimicking a human-in-the-loop debugging process.

Data and Complexity Levels

The benchmark comprises 124 tasks and 964 VIs, sourced from MBPP and DevEval. Tasks are categorized into three levels:

  • L-1: Standalone functions using standard libraries.
  • L-2: Intra-file or intra-class context requirements.
  • L-3: Cross-file repository-level context.

Results and Key Insights

The evaluation of state-of-the-art LLMs on CodeIF-Bench revealed several critical bottlenecks in interactive code generation.

The Instruction Forgetting Phenomenon

A core contribution of this work is the quantification of the Instruction Forgetting Ratio (IFR). The study found that as models attempt to satisfy new instructions, they often regress on previous ones. For example, adding a docstring might inadvertently lead the model to remove a previously implemented error handler.

Context Management and Performance Decay

Performance degrades significantly as dialogue history grows. Interestingly, the "noise" generated by the model's own previous responses often contributes more to this confusion than the instructions themselves. In L-2 scenarios involving repository context, even top-tier models like Claude 3.5 Sonnet saw instruction accuracy drop to 14.7% by the sixth turn.

Cumulative Instruction (CI) Prompting

To combat forgetting, the authors tested a "Cumulative Instruction" strategy. By providing only the aggregated list of user instructions and omitting previous model outputs, models achieved higher accuracy with lower token consumption. This suggests that current LLMs struggle to distinguish between relevant constraints and conversational filler in long histories.

Conclusion and Future Work

CodeIF-Bench exposes a significant gap between single-turn coding proficiency and multi-turn reliability. The "instruction forgetting" wall remains a major hurdle for deploying truly autonomous coding assistants. Future research should focus on adaptive context selection and specialized alignment techniques to ensure that LLMs can maintain long-term consistency across complex, repository-scale projects.

Summary updated

BibTeX
@misc{wang2025codeif,
  author = {Peiding Wang and Li Zhang and Fang Liu and Lin Shi and Minxiao Li and Bo Shen and An Fu},
  title = {{CodeIF-Bench: Evaluating Instruction-Following Capabilities of Large Language Models in Interactive Code Generation}},
  year = {2025},
  eprint = {2503.22688},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2503.22688},
}
Figure