ClarifyCodeBench: Evaluating LLMs on Clarifying Ambiguous Requirements for Code Generation

Zheng Fang, Dongming Jin, Yihong dong, Yongmin Li, Kechi Zhang, Zhi Jin, Ge LiarXiv 2026

TL;DR

While Large Language Models (LLMs) excel at generating code from pristine, textbook prompts, they struggle significantly when faced with real-world, ambiguous requirements. This paper introduces ClarifyCodeBench, an interactive benchmark that evaluates an LLM's ability to proactively ask clarifying questions rather than blindly guessing user intent. The findings reveal a striking "reasoning paradox": increasing an LLM's internal computational "thinking" improves code correctness but yields marginal gains in its ability to detect requirement ambiguities.

What Problem Does This Paper Address?

In real-world software engineering, requirements are rarely perfect; they are frequently incomplete, vague, or underspecified. However, standard code-generation benchmarks (like HumanEval or MBPP) evaluate LLMs in a single-turn, static setting where the problem description is completely specified.

When faced with ambiguity, current LLMs tend to make implicit assumptions and generate code based on guesswork, often leading to silent failures or incorrect implementations. To build robust AI programming assistants, we need models that can recognize what they don't know and interactively elicit requirements from the user. This paper addresses the lack of standardized frameworks to evaluate this interactive clarification bottleneck.

Figure 1: An ambiguous code generation requirement.

Methods

The authors formalize an interactive evaluation protocol consisting of a multi-round loop between the evaluated LLM and a benchmark environment:

  1. Interactive Loop: The model is given an ambiguous requirement and a strict system prompt. It must choose to either output the final code or ask exactly one clarification question.
  2. LLM-as-a-Judge: If the model asks a question, an LLM judge (GPT-4o) determines if it matches any of the pre-annotated "key questions" for that task. If it matches, the environment provides the ground-truth answer; if not, it returns a default "no ambiguity detected" response.
  3. Evaluation Metrics: To measure interaction quality and efficiency, the authors introduce two new metrics:
  4. Turn-discounted Key Question Rate (TKQR): Adapts Discounted Cumulative Gain (DCG) from information retrieval to reward models that uncover critical ambiguities early in the conversation while penalizing redundant or delayed questions.
  5. Optimal Round Adherence (ORA): Uses a Gaussian-shaped penalty to evaluate whether the model engages in the near-optimal number of interaction rounds, discouraging both premature code generation and endless, unnecessary questioning.
Figure 4: System prompt used in our interactive evaluation. The model must either output code or ask one clarification question.

Datasets

The authors introduce ClarifyCodeBench, constructed on top of the existing LiveCodeBench (v6) dataset to minimize data contamination risks.

  • Construction: Human annotators used "deletion-only editing" to remove crucial pieces of information from originally well-formed requirements, introducing 1 to 3 distinct ambiguity points per task.
  • Composition: The dataset contains 419 ambiguous tasks (199 with one ambiguity, 169 with two, and 51 with three). Each task includes the underspecified requirement, annotated key clarification questions/answers, and an executable test suite.
  • Taxonomy: Ambiguities are categorized into 10 fine-grained types, with Terminology and Output Format being the most prevalent.
Figure 3: Distribution of ambiguity types in Clarify- CodeBench. ClarifyCodeBench covers a diverse set of ambi- guity categories, with Terminology and Output Format being the most common.

Key Insights and Ideas

  • Capability Decoupling: Strong coding skills do not imply strong clarification skills. Models that excel at writing code from complete specifications often fail miserably at recognizing when a specification is incomplete.
  • The Reasoning Paradox: "Thinking" or reasoning models (e.g., Claude-Sonnet-4.5 or GPT-5 in reasoning modes) allocate their computational budget to internal inference and guessing rather than asking questions. While this internal reasoning helps them guess correctly more often, it does not improve their ability to proactively clarify ambiguities with the user.
  • The Multi-Ambiguity Ceiling: LLMs suffer a sharp performance degradation when a requirement contains multiple ambiguities. They might catch one missing detail but struggle to sustain a structured, multi-turn elicitation process to uncover the rest.
  • Uneven Ambiguity Handling: LLMs are reasonably good at identifying missing local constraints (like Units or Numerical Precision) but struggle deeply with semantics-heavy ambiguities, such as Collection Semantics or Ordering & Atomicity.

Key Results

The authors evaluated six state-of-the-art LLMs (including GPT-4o, GPT-5, Claude-Sonnet-4.5, and DeepSeek-V3.2):

  • Massive Performance Drops: Ambiguity severely degrades downstream code quality. For instance, GPT-5's functional correctness (pass@1) drops from 52.5% under complete requirements to just 32.0% when requirements are ambiguous.
  • Low Clarification Scores: Across the board, clarification quality metrics were low. DeepSeek-V3.2 achieved the highest scores, but still only reached a TKQR of 0.30 and an ORA of 0.50. Most other models scored below 0.30 on TKQR and 0.35 on ORA.
  • Premature Termination: Models consistently exhibited negative "turn differences" (Diff), meaning they asked significantly fewer questions than the tasks actually required, opting instead to generate code prematurely based on unverified assumptions.
Figure 2: Pass@1 (%) under four input settings: Complete Requirement (Full Req.), Ambiguous Requirement (Ambig. Req.), Interactive Clarification (Interact. Clar.), and Oracle Clarification (Oracle Clar.).

Limitations and Future Work

  • Isolation from Agentic Workflows: This study deliberately isolated model-level clarification under a controlled prompting setup. Real-world software agents utilize tools, repository contexts, and test executions, which could alter how ambiguities are handled. Extending this benchmark to full agentic workflows is a critical next step.
  • Data Leakage Risks: Because the benchmark is built on top of public competitive programming problems, closed-source models might have encountered the original, unabridged problem descriptions during pre-training, potentially leading them to "guess" correctly based on memory rather than context.
  • LLM-as-a-Judge Noise: While validated with a high Cohen's kappa (0.89) against human evaluation, using an LLM evaluator can still introduce minor residual noise in borderline cases.

Summary updated

BibTeX
@misc{fang2026clarifycodebench,
  author = {Zheng Fang and Dongming Jin and Yihong dong and Yongmin Li and Kechi Zhang and Zhi Jin and Ge Li},
  title = {{ClarifyCodeBench: Evaluating LLMs on Clarifying Ambiguous Requirements for Code Generation}},
  year = {2026},
  eprint = {2607.00711},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2607.00711},
}
Figure