CONTRA: Discovering and Qualifying Behavior-Changing Questions for Selective Clarification in LLM Code Generation

Zheng Fang, Yongmin Li, Yichang Zhang, Dongming Jin, Haoyu Wang +3 more
10/1/2026
cs.SEcs.AI

No confident code implementation found for this paper.

Abstract

Coding agents can generate code that appears correct but implements behavior the user never intended. This mismatch can arise when an agent silently resolves underspecified requirements through its own assumptions.

Show full abstract

As subsequent development builds on these assumptions, correcting the resulting behavior can become increasingly costly. Early clarification can help prevent such mismatches, but unnecessary questions can interrupt developers and slow down development. Existing methods struggle to identify key clarification questions while avoiding unnecessary ones. Therefore, we propose CONTRA, a training-free method that combines broad question discovery with semantic and execution-based question qualification. CONTRA first generates candidate questions and filters out those unrelated to required behavior or already resolved by the requirement. For each remaining question, it generates programs conditioned on two plausible answers and checks for stable behavioral differences on shared inputs. It then uses the interaction history to select among qualified questions or stop asking. Experiments on ClarifyCodeBench show that CONTRA achieves the highest F1 with all four coding agents, exceeding the best baseline macro-average F1 by 13.88 percentage points. With the same LLM and evaluation protocol, CONTRA also achieves higher clarification recall and F1 than the coding harnesses Claude Code and OpenHands. To support practical use, we also implement CONTRA as a Claude Code plugin that integrates selective clarification into everyday development.

View on arXivView PDF

Code Implementations

No confident code match yet

We couldn't find an author-owned or strongly-evidenced community implementation for this paper. Any repos shown below are weak matches — verify before relying on them.

No code implementations found yet.

Know of an implementation? Let us know in the comments below!

Similar Papers

Cite this paper

@article{fang2026contra,
  title  = {CONTRA: Discovering and Qualifying Behavior-Changing Questions for Selective Clarification in LLM Code Generation},
  author = {Zheng Fang and Yongmin Li and Yichang Zhang and Dongming Jin and Haoyu Wang and Shuai Wang and Zhi Jin and Ge Li},
  year   = {2026},
  eprint = {2610.01769},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2610.01769v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2610.01769.svg)](https://codeofpaper.com/paper/2610.01769)

Discussion