TLDR: A new benchmark, MT-Sec, evaluates AI coding assistants on multi-turn code generation for both correctness and security, revealing a 20-27% drop in secure outputs compared to single-turn tasks. The study, involving 32 LLMs and three agent frameworks, highlights challenges in maintaining coherence and integrating evolving requirements across iterative coding workflows, emphasizing the need for better multi-turn security evaluation.
AI coding assistants, powered by large language models (LLMs), have become indispensable tools in software development, significantly boosting developer productivity. While these tools are widely adopted, ensuring the correctness and, crucially, the security of the code they generate is paramount. Existing benchmarks for evaluating these LLMs primarily focus on single-turn tasks, where the model is prompted once to produce a complete solution. However, real-world software development is rarely a single-step process; it’s an iterative, multi-turn conversation where developers continuously refine, expand, and refactor code.
A new benchmark called MT-Sec has been introduced to address this gap. It is the first of its kind to systematically evaluate both the correctness and security of LLM-generated code in multi-turn coding scenarios. The creators of MT-Sec developed a synthetic data pipeline that transforms existing single-turn tasks into realistic multi-turn interaction sequences. This innovative approach allows them to reuse original test suites while accurately modeling the complexities of natural coding conversations.
The benchmark categorizes multi-turn interactions into three types: expansion, editing, and refactoring. Expansion involves incrementally introducing new functionality. Editing simulates back-and-forth revisions to an initial instruction. Refactoring focuses on restructuring code for clarity or modularity without altering its core behavior. These interaction types are designed to capture common software development workflows that involve planning and incremental reasoning.
In their evaluation, the researchers tested 32 open- and closed-source models, along with three agent-scaffolding systems, on MT-Sec. The findings revealed a consistent and significant drop of 20-27% in “correct & secure” outputs when models transitioned from single-turn to multi-turn settings, even among state-of-the-art models. This performance degradation worsened as the number of turns increased. The study also demonstrated that this decline isn’t merely due to increased context length; rather, it reflects fundamental challenges LLMs face in maintaining coherence across turns and integrating evolving requirements.
Beyond generating full programs, MT-Sec also evaluates models on multi-turn code-diff generation, a practically relevant but previously unexplored area. The results showed that models produced more incorrect and insecure code when generating code-diffs compared to generating full programs. Furthermore, while agent scaffoldings were found to boost single-turn secure code generation performance, they proved less effective in multi-turn scenarios.
Also Read:
- E2EDev: A New Benchmark Reveals LLMs Struggle with End-to-End Software Development Details
- The Hidden Deceptive Tendencies of Large Language Models
The research highlights a critical need for benchmarks that jointly evaluate correctness and security within the iterative, multi-turn nature of real-world coding workflows. The authors, Ruchit Rawal, Jeffrey Yang, Fan Chiang, Chihao Shen, Jeffery Siyuan Tian, Aastha Mahajan, Tom Goldstein, and Yizheng Chen from the University of Maryland, College Park, hope that MT-Sec will promote the safer deployment of LLMs in software engineering. You can read the full research paper for more details. Read the full paper here.


