原始采集文本
Proceedings of the 2026 Conference on Empirical Methods in Natural Language Processing , pages 45222–45258
October 24-29, 2026 ©2026 Association for Computational Linguistics
Benchmarking Correctness and Security in Multi-Turn Code Generation
Ruchit Rawal Jeffrey Yang Fan Chiang Chihao Shen Jeffery Siyuan Tian
Aastha Mahajan Tom Goldstein Yizheng Chen
University of Maryland, College Park
Abstract
AI coding assistants powered by large language
models (LLMs) have transformed software de-
velopment, significantly boosting productivity.
While existing benchmarks evaluate the correct-
ness and security of LLM-generated code, they
are limited to single-turn tasks that cannot cap-
ture the conversational nature of real-world de-
velopment, where requirements evolve across
turns and tools increasingly generate incremen-
tal diffs rather than complete programs. We in-
troduce MT-Sec, the first benchmark to jointly
evaluate correctness and security in multi-turn
coding scenarios. MT-Sec covers four inter-
action types (expansion,editing,refactoring,
anddebugging) reflecting common develop-
ment workflows. We construct multi-turn tasks
using human-curated instructions and feedback-
driven interactions grounded in dynamic test
suites. Evaluating 31 LLMs and 3 agent scaf-
folds, we find that models struggle most with
expansion and editing, but improve signifi-
cantly in debugging when provided with feed-
back. Agent-based systems often underperform
their base models in automated multi-turn set-
tings due to brittle tool use. We also evaluate
multi-turn code-diff generation, an unexplored
but practical setting, and observe higher fail-
ure rates compared to full-program generation.
Our findings underscore the need for multi-turn
benchmarks to drive safer AI-assisted develop-
ment.
1 Introduction
Coding agents powered by Large Language
Models (LLMs) have revolutionized software
development (Tabarsi et al., 2025; Rasnayaka et al.,
2024; Coutinho et al., 2024), boosting productivity
for millions of developers (Kalliamvakou, 2022;
Tabachnyk and Nikolov, 2022). However, as
these tools are increasingly adopted, there is an
urgent need to understand and mitigate the security
vulnerabilities they may introduce.
Recent works have proposed several benchmarks
to evaluate both functional correctness and secu-
rity of code generated by LLMs (Nie et al., 2026;
Peng et al., 2025; Vero et al., 2025; Shen et al.,
2025). While these benchmarks have made sig-
nificant progress, they share two key limitations
that may reduce how well their results general-
ize to real-world secure coding workflows.(1)
No conversational coding scenarios.Existing
benchmarks are limited to single-turn code genera-
tion, where the LLM receives one prompt and pro-
duces the entire output in a single pass. In practice,
real-world coding with LLMs is overwhelmingly
multi-turn: an empirical study of 82,845 developer–
LLM conversations finds that 68% involve multi-
ple turns (Zhong et al., 2025), driven by shifting
requirements (37.8%), clarifying missing specifica-
tions (14.8%), and requesting additional function-
ality (12.8%), among other factors (Zhong et al.,
2025; Zhang et al., 2025). Developers rarely pro-
vide a complete specification upfront; instead, they
refine their intent as intermediate outputs reveal
gaps. Multi-turn dialogues introduce substantially
richer context: prior code, intermediate model out-
puts, and evolving requirements accumulate across
turns, creating cross-turn dependencies entirely ab-
sent in single-turn settings. This makes it unclear
whether high single-turn scores reflect real-world
performance.(2) No tasks for code-diff genera-
tion.AI coding tools like Cursor (Cursor, 2025)
and GitHub Copilot (GitHub, 2025) increasingly
default to generating incremental code diffs rather
than complete programs. Producing a correct and
secure diff is a qualitatively different challenge
from clean-slate generation: models must identify
the correct edit location and integrate new require-
ments while preserving the correctness and security
of surrounding logic. No existing benchmark eval-
uates this setting.
Our Work.We introduce MT-Sec, a multi-turn
coding benchmark that evaluates secure coding
45222
Figure 1: Overview of MT-Sec. The benchmark comprises 2,638 multi-turn tasks spanning 27 CWEs and 6
programming languages. Each task follows one of four interaction types and is evaluated with dynamic correctness
and security tests after the final turn.
capabilities of LLMs in realistic software de-
velopment workflows (Figure 1). The classical
software maintenance taxonomy (Swanson, 1976;
Lientz and Swanson, 1980) states that virtually all
code changes fall into three categories: perfective
(adding or improving functionality), adaptive (re-
sponding to changed requirements), and corrective
(fixing defects). Drawing on this, we propose
four fundamental interaction types:expansion
incrementally introduces new functionality;editing
modifies or pivots code as requirements evolve;
refactoringrestructures code for modularity
or readability without altering behavior; and
debuggingiteratively fixes correctness and security
issues using test feedback. These four types
capture 97.7% of real-world developer-LLM
coding conversations in the CodeChat dataset (see
Appendix H). Since multi-turn interactions pro-
duce an evolving codebase, MT-Sec also enables
evaluation of code-diff generation, where models
produce incremental edits rather than full programs,
mirroring tools like Cursor and GitHub Copilot.
We construct multi-turn sequences in two ways.
For expansion, editing, and refactoring, instruction
sequences are LLM-generated for scalability,
then verified by three security experts who
independently evaluate each task for faithfulness
and interaction-type alignment, with all rejected
tasks manually rewritten (over 90 human hours
of expert review). For debugging, requests are
derived automatically from unit test execution on
the model’s output, producing dynamic interaction
flows grounded in human-written test cases.
Figure 2 illustrates concrete examples of all
four interaction types for the same underlying
task (URL validation). In the editing example,
a developer’s requirements pivot across turns:
the first turn asks for local file path validation,
the second shifts to network paths, and the third
changes direction entirely to web URLs. This
requires the model to reconcile new demands with
prior implementations while deciding what to
preserve, discard, and safely integrate.
MT-Sec contains 2,638 multi-turn tasks span-
ning 27 CWEs (Common Weakness Enumerations),
six programming languages, and four interaction
types. Evaluating 31 open- and closed-source mod-
els, we find that expansion and editing are the most
challenging, reducing the correct & secure rate by
15–27% relative to single-turn baselines, while de-
bugging with automated feedback can improve per-
formance by 25–30%. We show that this difficulty
stems from the cross-turn dependencies inherent to
multi-turn workflows (integrating code fragments
across turns, replacing prior implementations to
satisfy evolving requirements) rather than from
increased context length alone. We find that agent
scaffolds (Aider (Gauthier, 2023), Codex (OpenAI,
2025), and OpenHands (Wang et al., 2025)) often
underperform their base LLMs in multi-turn set-
tings, and code-diff generation yields lower correct
& secure rates than full-program generation.
2 Related Works
Multi-Turn Evaluation.For general natural lan-
guage conversations, benchmarks such as Multi-
IF (He et al., 2024), MT-Eval (Kwan et al., 2024),
and MultiChallenge (Deshpande et al., 2025) eval-
45223
Figure 2: Example multi-turn tasks for all four interaction types, grounded in URL/path validation. Expansion
incrementally builds functionality across turns; editing pivots requirements, requiring the model to revise prior
logic; refactoring restructures code without changing behavior; and debugging iteratively fixes issues using test
feedback. Each interaction type creates distinct cross-turn dependencies. See Appendix L for additional examples.
uate whether models can retain instructions, main-
tain coherence, and perform reliable revisions
across turns; across all three, frontier models drop
sharply from single-turn baselines, confirming that
multi-turn consistency remains an open problem.
In code generation, CodeGen (Nijkamp et al., 2022)
decomposes programming problems into sub-
instructions, MINT (Wang et al., 2023) evaluates
tool- and language-feedback, DebugBench (Tian
et al., 2024) studies program repair, and more re-
cent benchmarks such as ConvCodeWorld (Han
et al., 2025), CodeFlowBench (Wang et al., 2026),
and Talk2Code (Yang et al., 2026) extend eval-
uation to feedback-driven coding, iterative code
reuse, and user-stratified interaction. However, all
of these exclusively target functional correctness
and do not assess whether models preserve security
properties as code evolves across turns. Building
on this line of work, MT-Sec evaluates multi-turn
code generation under four development-oriented
interaction types and is the first to jointly measure
functional correctness and security across turns.
Security of Code LLMs.Evaluating the secu-
rity of LLM-generated code has become a growing
priority (Tabarsi et al., 2025; Rasnayaka et al.,
2024). Early benchmarks relied on static analyz-
ers (Pearce et al., 2025; Bhatt et al., 2023; Liu et al.,
2024), but generalize poorly due to high false-
positive/negative rates (Peng et al., 2025; Charoen-
wet et al., 2024). Dynamic-test-based benchmarks
address this: SECCODEPLT (Nie et al., 2026)
uses unit tests to assess correctness and security
across diverse CWEs, and BAXBENCH(Vero
et al., 2025) evaluates self-contained backend
applications. SecureVibeBench (Chen et al., 2026)
evaluates coding agents on 105 real-world C/C++
vulnerability scenarios from OSS-Fuzz, finding the
best agent achieves only 23.8% correct & secure.
All prior secure coding benchmarks operate in
single-turn settings. MT-Sec extends evaluation to
multi-turn interactions, code-diff generation, and
agent-based scaffolding.
3 Developing MT-Sec
Each instance in MT-Sec contains a sequence of
inter-dependent user requests and executable cor-
rectness and security tests for evaluating the result-
ing code (Figure 1). At each turn, the model must
integrate the current request with the code it has
produced so far, creating cross-turn dependencies.
We use two complementary construction paths: for
expansion, editing, and refactoring, we construct
three-turn request sequences verified by human an-
notators; for debugging, the trajectory is dynamic,
with later turns generated from test feedback on the
45224
model’s previous output.
Seed Prompt Collection.We select secure cod-
ing prompts from SECCODEPLT (Nie et al., 2026)
and BAXBENCH(Vero et al., 2025) that include
dynamic correctness and security tests (executable
unit tests run in a sandbox), since dynamic testing
is more reliable than static analysis (Peng et al.,
2025; Charoenwet et al., 2024). This yields approx-
imately 60% of SECCODEPLT tasks (the Python
split with function-level dynamic tests; 22–24
prompts per CWE across 17 CWEs) and all tasks
from BAXBENCH, each annotated with a CWE
type (MITRE Corporation, 2025). See Table 6 for
full CWE listings and language breakdowns.
Synthetic Dialogue Generation.We define
three interaction types:Expansionadds function-
ality incrementally;Editingmodifies or pivots
earlier code as requirements shift; andRefactoring
restructures code for modularity or readability
without changing behavior. For each seed prompt,
we generate three-turn instruction sequences using
GPT-4o with in-context examples, anchoring
all tasks to the same final coding objective as
the single-turn prompt to enable reuse of the
original test suites at the final turn. Crucially, each
interaction type introduces intermediate goals that
semantically expand the task rather than decom-
posing it into sub-steps, producing more realistic
dialogue patterns than prior decomposition-based
approaches (Nijkamp et al., 2022). Full prompt
templates for each interaction type are provided
in Appendix G. For intermediate-turn evaluation,
refactoring and debugging tasks reuse the original
test suites since the function interface is preserved
across turns. For expansion and editing, where
intermediate turns introduce different functionality,
we generate additional unit tests using GPT-4o
with task-specific prompts and in-context examples
tailored for test-case generation. Despite reusing
seed prompts, this transformation substantially
rewrites them: for expansion and editing, only
∼20–25% of a seed’s 8-grams reappear anywhere
in the dialogue (13–21% in the final turn) and
∼80% of the dialogue is new material, with the
retained overlap concentrated in the function
signature and typed-argument block that must stay
fixed for the reused tests to remain valid. Table 1
quantifies this at n= 4/8/10 : refactoring retains
most of the seed because its first turn restates the
task, whereas expansion and editing retain little
of it, and for all three interaction types the majority
of the dialogue is content the seed never contained.
Table 1: Verbatim n-gram overlap between each seed
prompt and its generated multi-turn dialogue, reported
as n= 4/8/10 (%).Retainedis the share of seed n-
grams that reappear in the dialogue (anywhere, or in the
final scored turn);New contentis the share of dialogue
n-grams absent from the seed. debugging is excluded,
as its turns are generated from test-execution feedback
rather than transformed from seed text.
Retained Retained New
Interaction (anywhere) (final turn) content
Expansion 27 / 22 / 20 17 / 13 / 12 79 / 82 / 83
Editing 32 / 25 / 23 27 / 21 / 19 75 / 80 / 81
Refactoring 81 / 74 / 70 0 / 0 / 0 51 / 55 / 57
See Appendix A.2 for the per-dataset breakdown
and further discussion.
Consistency Guardrail.To ensure compatibil-
ity with test cases, we apply rule-based consistency
guardrails that check the generated multi-turn
sequence against seed prompt metadata (e.g.,
function name, arguments, return types) and
interaction-type conventions. For example, if
the seed prompt specifies encrypt(data, key,
algorithm) but the generated sequence never
mentions the algorithm argument, the guardrail
flags a missing-argument violation and triggers
regeneration with targeted feedback (e.g., “the re-
quest is missing: algorithm parameter”). Similarly,
expansion tasks are flagged if they introduce the
target function name in the first turn (violating the
incremental build-up), and editing tasks must refer-
ence modification-related keywords in later turns.
Each interaction type has 4 guardrail rules, and ap-
proximately 18% of initially generated sequences
trigger at least one violation, requiring regeneration.
Tasks are regenerated up to three times; the full
rule set and additional details are in Appendix A.1.
Human Verification.Consistent with best prac-
tices in recent multi-turn benchmarks (He et al.,
2024; Kwan et al., 2024), we adopt a generate-
then-verify approach that balances task scalabil-
ity with quality. Specifically, two of the authors
and an external volunteer independently review
the LLM-generated multi-turn tasks along two di-
mensions: (i)task faithfulness, whether the multi-
turn instructions contain all information required
to run the original correctness and security tests,
and (ii)interaction-type alignment, whether the di-
alogue accurately reflects the intended interaction
type. Based on this review, 93.1% of tasks were
accepted by at least two annotators for task faith-
fulness, and 91.6% for interaction-type alignment
45225
(all three agreed unanimously on 90.3% and 88.2%
of tasks, respectively, with no systematic author-
versus-external divide; Appendix A.1). To check
the generated intermediate test cases, the authors
audited a random sample of 150 instances across
expansion and editing and found that 98.7% of tests
were well-aligned with their corresponding turn in-
structions, indicating that the pipeline produces reli-
able intermediate evaluations. Rejected tasks were
then manually rewritten before inclusion in the fi-
nal benchmark. In total, we spent over 90 human
hours on verification and correction, an estimated
180–270 hours less than fully manual construction.
Automated Feedback-Based Construction for
DebuggingWe construct multi-turn debugging
tasks using automated feedback derived from cor-
rectness and security test results, applied to a subset
of 262 tasks from SECCODEPLT selected for their
multiple-unit-test structure and dynamic test sup-
port. After each model response, we execute cor-
rectness and security tests and provide templated
natural language feedback indicating whether the
code fails correctness checks, contains security
vulnerabilities, or both. The interaction continues
until all issues are resolved or a maximum of five
turns is reached. Final performance is evaluated
on a held-out set of test cases disjoint from those
used for feedback, ensuring that both feedback and
evaluation are grounded in human-authored tests.
MT-Sec Statistics.MT-Sec includes 2,638
multi-turn tasks across six programming languages
(PYTHON, JAVASCRIPT, GO, PHP, RUBY, RUST),
generated from 792 seed prompts spanning 27
CWEs: 2,376 human-verified tasks (792 each for
expansion, editing, and refactoring) plus 262 de-
bugging tasks. Each task includes both correctness
and security unit tests. Our 27 CWEs span the
same weakness classes emphasized by MITRE’s
2025 CWE Top-25 (injection, access control,
cryptographic failures, resource exhaustion), and
include two categories that are new entries on the
2025 list (CWE-284, CWE-770). Unlike many
secure-coding benchmarks restricted to Python,
MT-Sec spans six languages while retaining
enough samples per CWE to break down perfor-
mance by individual weakness (Appendix I) and
keep the set manually auditable. See Appendix A
for per-CWE and per-language distributions.
Evaluation Metrics.We use two primary met-
rics:(i) Correct & Secure (C&S):the proportion
of instances that pass both correctness and secu-
rity tests; and(ii) Correct & Insecure (C&I):the
proportion that pass correctness tests but fail one
or more security tests. In certain analyses, we also
report the aggregated correctness metric (C&S +
C&I). Unless otherwise specified, we report met-
rics on the final code produced after all turns are
completed. We additionally evaluate intermediate-
turn outputs where noted (see §4). See Ap-
pendix A.1 for further details on evaluation setup.
4 Evaluations & Insights
Experimental Setup.We evaluate 31 open-source
and proprietary LLMs, as well as three state-of-
the-art open-source agent frameworks (Aider,
OpenHands, and Codex) on MT-Sec. We use
MT-SECCODEPLT to denote the subset of MT-Sec
constructed from SECCODEPLT prompts. Unless
otherwise noted, all reported MT metrics refer to
final-turn evaluation. Full details on model check-
points, evaluation protocols, prompt templates, and
computational costs are in Appendix B.
Although newer models achieve better secure
coding results in single-turn benchmarks, this
progress diminishes significantly in multi-turn
scenarios.To contextualize our findings, we high-
light a gap between single-turn and multi-turn eval-
uation. Across model families, rapid gains on
single-turn SecCodePLT (Nie et al., 2026) shrink
substantially in multi-turn settings: Claude Opus
4 improves over Claude 3.5 Sonnet by 13.2% on
SecCodePLT but only 4.7% on MT-Expansion, and
Qwen-38BT improves over Qwen-30.6BT by 31% on
SecCodePLT but only 10.7% on MT-Expansion.
Expansion and editing are consistently the
most challenging settings for secure code
generation.As shown in Table 2, even the
strongest models achieve only moderate C&S in
these regimes (roughly 36% and 42%), whereas
refactoring is more favorable (peaking at 47.9%
C&S), and debugging is substantially higher for
most large models (70–92% C&S with very low
C&I). GPT-5T achieves the best MT-average C&S
(52.7) and leads debugging (91.6 C&S, 3.1 C&I),
while Claude Opus 4T is tied for the top in editing
(41.7 C&S, tied with O3 Mini T) and is among
the top in refactoring (47.7 C&S, peaking at 47.9
for Claude Sonnet 4 T). Among open-weight
models, the recent Kimi-K2.7-Code and GLM-5.2
are strongest (48.6 and 47.7 MT-average C&S),
approaching the top proprietary systems while
still trailing GPT-5T (52.7). The interaction-type
ordering (expansion and editing hardest, refactor-
45226
Table 2: Multi-turn (MT) performance across interaction types. Higher correct & secure (C&S) and lower correct &
insecure (C&I) indicate better performance. Top three performers per column are bolded and the worst underlined.
MT-Average (C&S) is the mean C&S over all four interaction types; models are sorted by this MT-Average. Overall,
performance is lowest in expansion/editing, stable in refactoring, while debugging yields high C&S for strong
models. Thinking models are denoted by T.
MT-Expansion MT-Editing MT-Refactor MT-Debugging MT-Average
C&S↑C&I↓C&S↑C&I↓C&S↑C&I↓C&S↑C&I↓C&S↑
GPT-5T 34.911.9 40.0 14.1 44.3 10.591.6 3.1 52.7
Claude Opus 4T 30.8 14.741.713.547.711.1 84.0 3.451.0
GPT-5 MiniT 36.210.7 40.5 13.2 41.0 12.1 84.0 6.250.4
O4 MiniT 30.8 11.041.611.5 42.5 10.9 85.52.750.1
O3 MiniT 30.9 11.641.711.7 42.2 11.1 85.5 3.8 50.0
GPT-5T (Codex) 29.0 15.9 35.6 14.4 43.9 14.8 89.73.1 49.6
Claude Sonnet 4T 30.1 15.1 38.3 13.447.911.8 81.3 3.4 49.4
O3T 31.1 11.0 40.9 10.9 38.9 10.2 85.8 6.9 49.2
Kimi-K2.7-Code 31.712.7 38.8 12.445.614.0 78.4 3.2 48.6
O1T 28.8 11.6 38.8 12.7 42.2 11.0 84.0 4.2 48.5
GPT-5T (OpenHands) 27.2 17.5 35.1 16.1 40.3 14.090.93.4 48.4
Claude 3.7 SonnetT 30.2 13.9 39.0 13.2 44.7 11.6 77.5 6.2 47.8
GLM-5.2 30.7 13.2 35.9 12.7 42.9 13.7 81.4 3.4 47.7
GPT-5T (Aider) 25.7 14.8 38.8 13.8 43.0 10.4 82.2 4.1 47.4
Gemini 2.5 ProT 30.9 12.2 36.4 11.7 42.0 10.6 74.6 5.5 46.0
GPT-4.1 29.0 12.6 39.3 10.1 38.7 9.9 75.6 4.3 45.7
Claude 3.7 Sonnet 29.0 12.9 36.4 14.2 40.7 11.7 72.5 5.0 44.7
Gemma-4-31B-it 24.9 11.2 33.3 11.4 38.5 11.5 73.3 3.2 42.5
GPT-4o 26.7 10.5 29.4 12.5 35.6 9.9 77.8 5.0 42.4
Claude 3.5 Sonnet 26.1 10.6 28.4 10.2 32.2 9.0 69.1 4.6 38.9
Deepseek-V3 22.6 11.9 28.5 11.3 35.3 10.8 68.5 4.4 38.7
Qwen3-235B-A22BT 24.1 12.6 28.2 13.5 33.6 12.1 66.4 4.9 38.1
Gemini 2.5 FlashT 19.8 8.5 22.4 8.0 27.18.073.0 3.2 35.6
Qwen-38B
T 15.7 10.9 19.1 8.6 23.9 8.9 57.9 3.9 29.1
Qwen-38B 14.8 10.5 16.3 10.3 23.3 8.7 61.23.128.9
Qwen-2.5 Coder7B 14.2 10.1 19.6 9.0 19.2 10.3 54.8 4.6 27.0
Qwen-34B
T 14.3 8.6 15.5 9.4 19.3 8.5 56.5 4.1 26.4
Qwen-34B 13.4 9.5 15.6 9.8 19.4 9.5 52.7 4.3 25.3
Qwen-2.5 Coder3B 10.9 9.6 11.5 9.5 11.9 10.6 40.3 4.3 18.7
Qwen-31.7B
T 8.8 6.7 11.3 9.1 13.8 8.7 32.7 8.7 16.6
Qwen-31.7B 8.5 8.1 9.57.610.1 9.8 30.3 8.4 14.6
Qwen-30.6B
T 5.06.13.0 6.64.68.216.9 20.9 7.4
Qwen-30.6B 2.4 4.03.4 8.9 5.1 9.2 15.1 18.0 6.5
Qwen-2.5 Coder0.5B 4.55.24.26.03.0 7.613.9 8.0 6.4
ing easier, debugging highest) and the single- to
multi-turn drop hold across every open-weight
family we evaluate (Kimi, GLM, DeepSeek,
Gemma, and Qwen). For instance, expansion falls
45.5→31.7 for Kimi and 43.5→30.7 for GLM, so
the degradation is not specific to any one family.
Scaling within a family helps but does not close the
gap: Qwen3-235B-A22BT improves MT-average
over Qwen-38BT (38.1 vs. 29.1) while still degrad-
ing sharply across turns. Notably, C&I remains
low for top-performing models in debugging
(typically 2.7–6.9), but rises in expansion/editing,
indicating that the hardest MT settings degrade
both correctness-and-security simultaneously.
Intermediate-turn evaluation (Figure 10) reveals
that C&S declines monotonically across turns for
expansion, with the performance gap between
models shrinking at each successive turn. This
suggests that stronger models are not merely
better at individual turns but are disproportionately
affected by accumulating cross-turn dependencies.
Similar trends hold for editing and refactoring; for
debugging (up to five turns, with early exit when
all tests pass), C&S increases rapidly at Turn 2
and then saturates (Appendix K). To understand
whymodels fail, we categorize errors across
failing multi-turn samples using a manual-error
analysis taxonomy followed by LLM-as-a-judge
classification (Zheng et al., 2023; Deshpande et al.,
2025; Kim et al., 2025). We identify three dom-
inant failure modes: (1) security neglect (60.3%),
where models drop security constraints (input
validation, sanitization, access control) as new turn
instructions shift attention; (2) scope narrowing
45227
(28.5%), where models implement the latest turn
too literally, losing broader task specifications;
and (3) context loss (9.0%), where setup code
or helper functions from earlier turns are silently
dropped (the remaining 2.2% are uncategorized
failures, e.g., syntax errors or refusals). Overall,
63% of failures are security-specific, confirming
that multi-turn settings disproportionately erode
security rather than general correctness. Due
to space constraints, we provide details on the
LLM judge setup, qualitative examples, and per-
interaction-type breakdowns in Appendix D. These
proportions hold stable across three judge models
and four prompt variants (twelve configurations
in all; Appendix D.4).
Agent scaffolds underperform their underly-
ing base modelsacross MT settings, with particu-
larly weak performance in expansion and elevated
insecurity rates. For example, GPT-5 T (Aider)
achieves 25.7 C&S in MT-expansion and 47.4 MT-
average C&S overall, while GPT-5T (OpenHands)
attains 27.2 C&S in MT-expansion and exhibits the
highest C&I among the reported systems in both
expansion (17.5) and editing (16.1). These drops
are accompanied by characteristic failure modes
(tool invocation errors, multi-file confusion, and
incorrect file generation) that compound across
turns. Since coding agents are typically designed
to solicit human confirmation when uncertain, we
confirm all actions programmatically to enable
scalable evaluation; this fully automated, mostly
single-file, specification-only regime (without
human-in-the-loop correction or realistic repository
context) may amplify scaffold-level errors that
human oversight would catch in practice. Detailed
agent configurations are in Appendix E.1, a taxon-
omy of failure modes in Appendix F, full results in
Appendix C.4 and C.5, and Appendix C.3 shows
that agent performance improves significantly with
oracle execution feedback.
Thinking models exhibit spurious refusals as
context accumulates.While “thinking” models
typically outperform their non-thinking counter-
parts, we observe a tendency to refuse multi-turn
requests that they handle successfully in single-turn
settings. For instance, in an MT-editing task,
Claude Sonnet 4T correctly implements safe arith-
metic evaluation in an early turn, but refuses when
the task evolves to executing general Python scripts
under the same safety constraints, responding: “I
can’t help create a function that executes arbitrary
user-supplied operations even with safety checks
in place...”. The model handles the equivalent
single-turn prompt without issue, suggesting that
accumulated context triggers overly cautious safety
filters. This behavior is most prevalent in CWE-95
tasks (Improper Neutralization of Directives in
Dynamically Evaluated Code): no refusals occur
in single-turn, but measurable rates appear in multi-
turn editing and expansion. Claude Sonnet 4T and
O3T are most affected (2.7% and 0.8% over-refusal
rates respectively), identified via regex-based
heuristics and manual verification. These rates are
conservative and may under-report true frequency.
Table 3: Correctness & security / insecurity when
models generate full code (MT) vs. code-diffs (MT +
CodeDiff) on a split of MT-Sec (editing). Deltas and p-
values (paired McNemar’s test:∗p <0.05 ,†p <0.01 ,
‡p <0.001) are relative to the MT column.
MT MT + CodeDiff
C&S↑C&I↓C&S↑C&I↓
O4 MiniT 48.1 14.5 37.7 ‡(−10.5) 19.2†(+4.7)
O3T 46.9 13.7 44.6(−2.2) 15.5(+1.7)
(Aider)+ O3 T 45.4 12.7 42.9(−2.5) 13.5(+0.8)
Qwen-2.5 Coder32B 42.9 14.2 22.6‡(−20.3) 14.8(+0.6)
GPT-4o 40.1 16.0 29.1‡(−11.1) 19.8∗(+3.8)
Claude 3.7 Sonnet 39.4 19.0 29.7 ‡(−9.7) 22.4(+3.5)
The difficulty of multi-turn tasks stems from
cross-turn dependencies, not longer context.A
natural question is whether the task difficulty in
the multi-turn setting is primarily due to increased
input length rather than challenges unique to multi-
turn reasoning. To isolate this, we introduceMT-
Random, which preserves the three-turn structure
but replaces the first two turns with prompts from
unrelated tasks (different CWEs), keeping only the
final turn as the target. This removes cross-turn de-
pendencies while maintaining or exceeding the in-
put length of standard multi-turn tasks (e.g.,∼566
tokens vs. 277.4 in EXPANSION). We conduct this
experiment on MT-SECCODEPLT. Results for
four models across three families (Fig. 3) show
that MT-Random performance closely matches or
slightly exceeds Single-Turn results. For example,
GPT-4o achieves 52.2% in Single-Turn, 52.5% in
MT-Random, but drops to 31.7% in MT-Expansion.
While some open-source models (e.g., Qwen3 8B)
show modest declines in MT-Random (6%), these
are smaller than drops in MT-Expansion (12%)
or MT-Editing (8%). This comparison yields two
key insights: (i) increased input length alone does
not account for the performance drop; and (ii) the
degradation in realistic multi-turn settings arises
45228
ST
MT-RandomMT-Expansion
MT-EditingMT-RefactorMT-Debugging
0
25
50
75
100
Performance
(%)
36.2 33.2 21.0 28.7 34.2
52.7
Qwen-34B
ST
MT-RandomMT-Expansion
MT-EditingMT-RefactorMT-Debugging
36.0 30.2 24.2 28.2 38.4
61.2
Qwen-38B
ST
MT-RandomMT-Expansion
MT-EditingMT-RefactorMT-Debugging
47.8 48.2 35.2 39.4 51.6
72.5
Claude 3.7 Sonnet
ST
MT-RandomMT-Expansion
MT-EditingMT-RefactorMT-Debugging
52.2 52.5
31.7 40.1 50.9
77.8
GPT-4o
Correct & Secure Correct & Insecure Incorrect
Figure 3: Performance comparison between Single-Turn (ST), standard Multi-Turn (MT) settings, and a control
condition, MT-Random on MT-SECCODEPLT. In MT-Random, context length is matched to MT by including
unrelated prior turns, isolating the effect of longer input without introducing cross-turn dependencies. Results across
four models show that performance in MT-Random is comparable to, or slightly better than, ST, indicating that
increased input length alone does not cause degradation.
from the added complexity of reasoning over
related turns–requiring models to track evolving
goals, modify prior code, and maintain coherence
across interactions. While MT-Random controls
for total context length, it does not address the
possible impact of target task length. We analyze
this separately in Appendix C.1 and find that
variation in task length does not explain the sharp
performance decline in multi-turn scenarios.
Effect of security-policy on multi-turn.Prior
work (Nie et al., 2026; Vero et al., 2025) shows that
appending a short security policy (e.g., “Ensure
query execution avoids eval() or exec() to pre-
vent untrusted code execution”) improves single-
turn performance. We examine whether this trans-
fers to multi-turn by inserting the policy at differ-
ent points (system prompt, first turn, last turn, or
every turn) and evaluate on expansion using MT-
SECCODEPLT (Table 4). Even with the best place-
ment, multi-turn performance remains below the
single-turn baseline without any policy. Only suf-
ficiently capable models benefit: smaller models
show modest gains (2–4%), while O3 T, GPT-4o,
and Claude 3.7 Sonnet achieve substantial gains (3–
14% depending on placement, with best-policy im-
provements of 8–14%). Optimal placement varies
by model family: OpenAI models perform best
with last-turn placement (e.g., O3 T: 49.4% C&S
vs. 47.1% with every-turn), as repeating the policy
can cause models to revise previously correct secu-
rity logic, while Claude 3.7 Sonnet benefits from
every-turn placement (see Appendix D). Notably,
even in single-turn, policy-based prompting sig-
nificantly underperforms test-case-based feedback
(i.e., debugging), suggesting that natural language
reminders are not the optimal form of security guid-
ance.
Code-diff generation reduces secure coding
rates and increases the proportion of insecure
outputs.To evaluate this increasingly common
mode of interaction, we design an experiment
where LLMs generate full code in Turn-1, followed
by unified-diff-style code patches in Turns 2 and
3 on MT-SECCODEPLT. Each generated diff is
programmatically applied to the existing code to
reconstruct the complete program for evaluation,
with the LLM provided the current code state and
relevant context at each turn.
Results are shown in Table 3 for editing
interaction type; most rows are pure LLMs, with
the third using Aider (additional agent analyses
in Appendix C.6). Across all models, we observe
a consistent decline in correctness & security
performance in the code-diff setting compared
to full-code generation, indicating that current
models struggle with targeted edits that must
preserve the security of surrounding code. More
concerningly, C&I increases across the board,
highlighting the risks of relying on code-diff
generation in security-sensitive contexts.
Additional Empirical Investigations.We
document recurring qualitative failure modes
observed across models, and how strategies to
address them help (Appendix D), the effect of
increasing the number of turns (Appendix C.2), the
effect of providing execution feedback to coding
agents (Appendix C.3), and ablation studies on the
Aider agent (Appendices C.4, C.5, C.6).
5 Discussion & Conclusions
We introduced MT-Sec, a benchmark for evaluat-
ing LLMs on multi-turn secure coding tasks across
45229
Table 4: Single-turn (ST) and multi-turn (MT) performance, reported as mean (%) showing only CS metric. Policy
blocks show the absolute value, ∆ from their baseline (ST or MT), and p-value (paired McNemar’s test:∗p <0.05 ,
†p <0.01, ‡p <0.001). For each model, the best-performing MT policy (highest CS) is highlighted in green.
ST ST + Sec. Policy MT MT + SysPrompt MT + First-Turn MT + Last-Turn MT + Every-Turn
CS↑CS↑CS↑CS↑CS↑CS↑CS↑
(Aider)+ O3 T 67.2 78.3 (+11.1) 44.3 51.5 †(+7.2) 51.1†(+6.8) 54.4‡(+10.1) 51.0†(+6.7)
O3T 57.5 66.8 ‡(+9.3) 41.4 46.1 ∗(+4.7) 44.6(+3.2) 49.4‡(+8.0) 47.1∗(+5.7)
O4 MiniT 56.8 65.5 ‡(+8.8) 38.7 43.1 (+4.5) 43.6∗(+5.0) 45.1†(+6.5) 41.9(+3.2)
GPT-4o 52.2 60.0 ‡(+7.8) 31.7 42.4 ‡(+10.7) 40.4‡(+8.7) 45.4‡(+13.7) 40.9‡(+9.2)
Claude 3.7 Sonnet 47.8 53.2 †(+5.5) 35.2 44.1 ‡(+9.0) 45.4‡(+10.2) 43.6‡(+8.5) 46.6‡(+11.5)
Qwen-38B 36.0 43.5 †(+7.5) 24.2 29.1 ∗(+5.0) 36.4‡(+12.2) 35.3‡(+11.1) 33.9‡(+9.7)
Qwen-34B 36.2 41.2 ∗(+5.0) 21.0 23.9 (+2.9) 24.7(+3.7) 30.4‡(+9.4) 23.9(+2.9)
Qwen-31.7B 19.8 27.5 ‡(+7.8) 14.3 14.0 (−0.3) 12.8(−1.5) 15.0(+0.8) 17.2(+2.9)
Qwen-30.6B 8.0 9.5 (+1.5) 2.8 5.8∗(+3.0) 5.2(+2.5) 4.8(+2.0) 3.0(+0.3)
four realistic interaction types:expansion,editing,
refactoring, anddebugging. Our evaluation of 31
models and three agent frameworks reveals that
multi-turn interactions remain a significant chal-
lenge for current LLMs. We find thatexpansion
andeditingare the most difficult interaction types,
often resulting in correct but insecure code due to
difficulties integrating changes while preserving
security constraints. Surprisingly, agent-based sys-
tems often underperform their base LLMs in multi-
turn settings, struggling with tool errors and coor-
dination issues when feedback or context evolves.
Beyond quantitative results, MT-Sec provides qual-
itative insights into key model failure modes, such
as: (1) neglecting security constraints as new turn
instructions shift attention (security neglect); (2)
implementing the latest turn too literally, losing
broader task specifications (scope narrowing); and
(3) silently dropping setup code or helper functions
from earlier turns (context loss).
6 Limitations
In this section, we discuss key limitations of
our work and potential for future improvements.
Our human-verified tasks focus on three-turn dia-
logues; while preliminary experiments extend to
10 turns (Appendix C.2), scaling expert verification
to longer sequences while maintaining quality con-
trol and reproducibility remains an open challenge.
Our debugging interaction uses templated unit-test
feedback, which we show is more reliable than
LLM-simulated user feedback (Appendix J); future
work could broaden this to additional feedback sig-
nals, such as developer-authored natural-language
critiques. We also leave training LLMs on curated
multi-turn secure coding data to future work; MT-
Sec can support this direction by guiding both data
generation and evaluation at scale.
7 Ethical considerations
Insecure code generated by LLMs can lead to crit-
ical vulnerabilities, exposing systems to outages,
data breaches, and exploitation by malicious actors.
Our benchmark provides a realistic, multi-turn eval-
uation framework that reflects how code is written
in practice. We believe that systematically measur-
ing LLMs’ secure coding capabilities is a necessary
step toward building safer AI-assisted development
tools. However, releasing such benchmarks may
also enable adversaries to identify blind spots in
current models, which could be misused; we en-
courage responsible use and continued research
into improving model security.
Acknowledgments
This research was supported in part by Coefficient
Giving, an NSF CAREER Award CNS-2442719,
DARPA TIAMAT and the NSF TRAILS Institute
(2229885), commercial support from Capital One
Bank, the Amazon Research Award program, and
generous gifts from Google DeepMind and Ope-
nAI.
References
Manish Bhatt, Sahana Chennabasappa, Cyrus Niko-
laidis, Shengye Wan, Ivan Evtimov, Dominik Gabi,
Daniel Song, Faizan Ahmad, Cornelius Aschermann,
Lorenzo Fontana, Sasha Frolov, Ravi Prakash Giri,
Dhaval Kapil, Yiannis Kozyrakis, David LeBlanc,
James Milazzo, Aleksandar Straumann, Gabriel Syn-
naeve, Varun V ontimitta, and 2 others. 2023. Purple
llama cyberseceval: A secure coding benchmark for
language models.Preprint, arXiv:2312.04724.
45230
Wachiraphan Charoenwet, Patanamon Thongtanunam,
Van-Thuan Pham, and Christoph Treude. 2024. An
empirical study of static analysis tools for secure code
review. InProceedings of the 33rd ACM SIGSOFT
International Symposium on Software Testing and
Analysis, pages 691–703.
Junkai Chen, Huihui Huang, Yunbo Lyu, Junwen An,
Jieke Shi, Chengran Yang, Ting Zhang, Haoye Tian,
Yikun Li, Zhenhao Li, Xin Zhou, Xing Hu, and
David Lo. 2026. SecureVibeBench: Benchmarking
secure vibe coding of AI agents via reconstructing
vulnerability-introducing scenarios. InProceedings
of the 64th Annual Meeting of the Association for
Computational Linguistics (Volume 1: Long Papers),
pages 24144–24168, San Diego, California, United
States. Association for Computational Linguistics.
Mariana Coutinho, Lorena Marques, Anderson San-
tos, Marcio Dahia, César França, and Ronnie
de Souza Santos. 2024. The role of generative ai
in software development productivity: A pilot case
study.ArXiv, abs/2406.00560.
Cursor. 2025. Cursor. https://www.cursor.com/ .
Accessed: 2025-05-09.
Kaustubh Deshpande, Ved Sirdeshmukh, Johannes Bap-
tist Mols, Lifeng Jin, Ed-Yeremai Hernandez-
Cardona, Dean Lee, Jeremy Kritz, Willow E Primack,
Summer Yue, and Chen Xing. 2025. Multichallenge:
A realistic multi-turn conversation evaluation bench-
mark challenging to frontier llms. InFindings of
the Association for Computational Linguistics: ACL
2025, pages 18632–18702.
Paul Gauthier. 2023. Aider: Ai-assisted coding in your
terminal with gpt. https://aider.chat/ . Ac-
cessed: 2025-05-15.
GitHub. 2025. Github copilot. https://github.com
/features/copilot. Accessed: 2025-05-09.
Hojae Han, Seung-won Hwang, Rajhans Samdani,
and Yuxiong He. 2025. Convcodeworld: Bench-
marking conversational code generation in repro-
ducible feedback environments.arXiv preprint
arXiv:2502.19852.
Yun He, Di Jin, Chaoqi Wang, Chloe Bi, Karishma
Mandyam, Hejia Zhang, Chen Zhu, Ning Li, Tengyu
Xu, Hongjiang Lv, Shruti Bhosale, Chenguang Zhu,
Karthik Abinav Sankararaman, Eryk Helenowski,
Melanie Kambadur, Aditya Tayade, Hao Ma, Han
Fang, and Sinong Wang. 2024. Multi-if: Benchmark-
ing llms on multi-turn and multilingual instructions
following.Preprint, arXiv:2410.15553.
Eirini Kalliamvakou. 2022. Research: quantifying
GitHub Copilot’s impact on developer productivity
and happiness. https://github.blog/news-ins
ights/research/research-quantifying-git
hub-copilots-impact-on-developer-product
ivity-and-happiness/ . GitHub Blog. Accessed:
2026-08-30.
Myeongsoo Kim, Shweta Garg, Baishakhi Ray, Varun
Kumar, and Anoop Deoras. 2025. Codeassistbench
(cab): Dataset & benchmarking for multi-turn chat-
based code assistance.Advances in Neural Informa-
tion Processing Systems, 38.
Wai-Chung Kwan, Xingshan Zeng, Yuxin Jiang, Yufei
Wang, Liangyou Li, Lifeng Shang, Xin Jiang, Qun
Liu, and Kam-Fai Wong. 2024. MT-eval: A multi-
turn capabilities evaluation benchmark for large lan-
guage models. InProceedings of the 2024 Confer-
ence on Empirical Methods in Natural Language Pro-
cessing, pages 20153–20177, Miami, Florida, USA.
Association for Computational Linguistics.
Bennett P. Lientz and E. Burton Swanson. 1980.Soft-
ware Maintenance Management. Addison-Wesley
Longman Publishing Co., Inc., USA.
Zefang Liu, Jialei Shi, and John F Buford. 2024. Cy-
berbench: A multi-task benchmark for evaluating
large language models in cybersecurity. InAAAI
2024 Workshop on Artificial Intelligence for Cyber
Security.
MITRE Corporation. 2025. Common weakness enumer-
ation (cwe) list, version 4.17. https://cwe.mitre.
org/data/index.html. Accessed: 2025-05-12.
Saikat Mondal, Suborno Deb Bappon, and Chanchal K.
Roy. 2024. Enhancing user interaction in chatgpt:
Characterizing and consolidating multiple prompts
for issue resolution. InProceedings of the 21st Inter-
national Conference on Mining Software Reposito-
ries, MSR ’24, page 222–226, New York, NY , USA.
Association for Computing Machinery.
Yuzhou Nie, Zhun Wang, Yu Yang, Ruizhe Jiang,
Yuheng Tang, Xander Davies, Yarin Gal, Bo Li,
Wenbo Guo, and Dawn Song. 2026. SECODEPLT:
A unified benchmark for evaluating the security risks
and capabilities of code genAI. InThe Thirty-ninth
Annual Conference on Neural Information Process-
ing Systems Datasets and Benchmarks Track.
Erik Nijkamp, Bo Pang, Hiroaki Hayashi, Lifu Tu, Huan
Wang, Yingbo Zhou, Silvio Savarese, and Caiming
Xiong. 2022. Codegen: An open large language
model for code with multi-turn program synthesis.
arXiv preprint arXiv:2203.13474.
OpenAI. 2025. Openai codex cli: Lightweight coding
agent that runs in your terminal. https://github
.com/openai/codex. [Accessed 15-05-2025].
Hammond Pearce, Baleegh Ahmad, Benjamin Tan,
Brendan Dolan-Gavitt, and Ramesh Karri. 2025.
Asleep at the keyboard? assessing the security of
github copilot’s code contributions.Communications
of the ACM, 68(2):96–105.
Jinjun Peng, Leyi Cui, Kele Huang, Junfeng Yang, and
Baishakhi Ray. 2025. Cweval: Outcome-driven eval-
uation on functionality and security of llm code gen-
eration.Preprint, arXiv:2501.08200.
45231
Sanka Rasnayaka, Guanlin Wang, Ridwan Shariffdeen,
and Ganesh Neelakanta Iyer. 2024. An empirical
study on usage and perceptions of llms in a soft-
ware engineering project.2024 IEEE/ACM Inter-
national Workshop on Large Language Models for
Code (LLM4Code), pages 111–118.
Chihao Shen, Connor Dilgren, Purva Chiniya, Luke
Griffith, Yu Ding, and Yizheng Chen. 2025. Secre-
pobench: Benchmarking code agents for secure code
completion in real-world repositories.arXiv preprint
arXiv:2504.21205.
E Burton Swanson. 1976. The dimensions of main-
tenance. InProceedings of the 2nd international
conference on Software engineering, pages 492–497.
Maxim Tabachnyk and Stoyan Nikolov. 2022. ML-
enhanced code completion improves developer pro-
ductivity. https://research.google/blog/m
l-enhanced-code-completion-improves-dev
eloper-productivity/ . Google Research Blog.
Accessed: 2026-08-30.
Benyamin Tabarsi, Heidi Reichert, Ally Limke, Sandeep
Kuttal, and Tiffany Barnes. 2025. Llms’ reshaping of
people, processes, products, and society in software
development: A comprehensive exploration with
early adopters.arXiv preprint arXiv:2503.05012.
Runchu Tian, Yining Ye, Yujia Qin, Xin Cong, Yankai
Lin, Yinxu Pan, Yesai Wu, Hui Haotian, Liu We-
ichuan, Zhiyuan Liu, and Maosong Sun. 2024. De-
bugBench: Evaluating debugging capability of large
language models. InFindings of the Association for
Computational Linguistics: ACL 2024, pages 4173–
4198, Bangkok, Thailand. Association for Computa-
tional Linguistics.
Mark Vero, Niels Mündler, Victor Chibotaru, Veselin
Raychev, Maximilian Baader, Nikola Jovanovi ´c,
Jingxuan He, and Martin Vechev. 2025. Baxbench:
Can LLMs generate correct and secure backends? In
Forty-second International Conference on Machine
Learning.
Sizhe Wang, Zhengren Wang, Dongsheng Ma, Yongan
Yu, Rui Ling, Zhiyu li, Feiyu Xiong, and Wentao
Zhang. 2026. CodeFlowBench: A multi-turn, iter-
ative benchmark for complex code generation. In
Proceedings of the 64th Annual Meeting of the As-
sociation for Computational Linguistics (Volume 1:
Long Papers), pages 4369–4402, San Diego, Cali-
fornia, United States. Association for Computational
Linguistics.
Xingyao Wang, Boxuan Li, Yufan Song, Frank F. Xu,
Xiangru Tang, Mingchen Zhuge, Jiayi Pan, Yueqi
Song, Bowen Li, Jaskirat Singh, Hoang H. Tran,
Fuqiang Li, Ren Ma, Mingzhang Zheng, Bill Qian,
Daniel Shao, Niklas Muennighoff, Yizhe Zhang,
Binyuan Hui, and 5 others. 2025. Openhands: An
open platform for AI software developers as gener-
alist agents. InThe Thirteenth International Confer-
ence on Learning Representations.
Xingyao Wang, Zihan Wang, Jiateng Liu, Yangyi
Chen, Lifan Yuan, Hao Peng, and Heng Ji. 2023.
Mint: Evaluating llms in multi-turn interaction
with tools and language feedback.arXiv preprint
arXiv:2309.10691.
Weibin Yang, Liangru Xie, Jieyun Cai, Yuxiang Yan,
Hong-Ning Dai, and Hao Wang. 2026. Talk2code:
A multi-turn interaction benchmark with dual-track
evaluation for code generation. InProceedings of
the AAAI Conference on Artificial Intelligence, vol-
ume 40, pages 34331–34339.
Binquan Zhang, Li Zhang, Haoyuan Zhang, Fang Liu,
Song Wang, Bo Shen, An Fu, and Lin Shi. 2025.
Decoding human-llm collaboration in coding: An
empirical study of multi-turn conversations in the
wild.arXiv preprint arXiv:2512.10493.
Kunhao Zheng, Juliette Decugis, Jonas Gehring, Taco
Cohen, Benjamin Negrevergne, and Gabriel Syn-
naeve. 2024. What makes large language models rea-
son in (multi-turn) code generation?arXiv preprint
arXiv:2410.08105.
Lianmin Zheng, Wei-Lin Chiang, Ying Sheng, Siyuan
Zhuang, Zhanghao Wu, Yonghao Zhuang, Zi Lin,
Zhuohan Li, Dacheng Li, Eric Xing, Hao Zhang,
Joseph E. Gonzalez, and Ion Stoica. 2023. Judging
LLM-as-a-judge with MT-bench and chatbot arena.
InThirty-seventh Conference on Neural Information
Processing Systems Datasets and Benchmarks Track.
Suzhen Zhong, Ying Zou, and Bram Adams. 2025.
Developer-llm conversations: An empirical study
of interactions and generated code quality.arXiv
preprint arXiv:2509.10402.
45232
Appendix
A Additional Benchmark Details
A.1 Additional Construction & Evaluation
Details
Table 5: All open-source models are available via Hug-
gingFace, and proprietary models are available via re-
spective providers. Some thinking and non-thinking
models may have the same model-checkpoint, as there
are often separate hyper-parameters to set thinking bud-
get to zero.
Model Name Checkpoint
GPT-5T gpt-5-2025-08-07
GPT-5-MiniT gpt-5-mini-2025-08-07
GPT-4o gpt-4o-2024-11-20
GPT-4.1 gpt-4.1-2025-04-14
O1-MiniT o1-mini-2024-09-12
O3-MiniT o3-mini-2025-01-31
O1T o1-2024-12-17
O4-MiniT o4-mini-2025-04-16
O3T o3-2025-04-16
Claude 3.7 Sonnet claude-3-7-sonnet-20250219
Claude 3.5 Sonnet claude-3-5-sonnet-20240620
Claude 3.7 SonnetT claude-3-7-sonnet-20250219
Claude Sonnet 4T claude-sonnet-4-20250514
Claude Opus 4T claude-opus-4-20250514
Gemini-2.5-FlashT gemini-2.5-flash-preview-04-17
Gemini-2.5-Flash gemini-2.5-flash-preview-04-17
Gemini-2.5-ProT gemini-2.5-pro-preview-03-25
Gemini-2.5-Pro gemini-2.5-pro-preview-03-25
Qwen2.5 Coder 32B Qwen/Qwen2.5-Coder-32B-Instruct
Qwen2.5 Coder 14B Qwen/Qwen2.5-Coder-14B-Instruct
Qwen2.5 Coder 7B Qwen/Qwen2.5-Coder-7B-Instruct
Qwen2.5 Coder 3B Qwen/Qwen2.5-Coder-3B-Instruct
Qwen2.5 Coder 1.5B Qwen/Qwen2.5-Coder-1.5B-Instruct
Qwen2.5 Coder 0.5B Qwen/Qwen2.5-Coder-0.5B-Instruct
Qwen3 32B Qwen/Qwen3-32B
Qwen3 32BT Qwen/Qwen3-32B
Qwen3 14B Qwen/Qwen3-14B
Qwen3 14BT Qwen/Qwen3-14B
Qwen3 8B Qwen/Qwen3-8B
Qwen3 8BT Qwen/Qwen3-8B
Qwen3 4B Qwen/Qwen3-4B
Qwen3 4BT Qwen/Qwen3-4B
Qwen3 1.7B Qwen/Qwen3-1.7B
Qwen3 1.7BT Qwen/Qwen3-1.7B
Qwen3 0.6B Qwen/Qwen3-0.6B
Qwen3 0.6BT Qwen/Qwen3-0.6B
Kimi-K2.7-Code moonshotai/Kimi-K2.7-Code
GLM-5.2 zai-org/GLM-5.2
Deepseek-V3 deepseek-ai/DeepSeek-V3
Gemma-4-31B-it google/gemma-4-31B-it
Qwen3-235B-A22BT Qwen/Qwen3-235B-A22B
Guardrails for different interaction types.
Consistency guardrails are lightweight, rule-based
checks that verify whether the generated multi-
turn instructions remain semantically aligned with
the original single-turn prompt metadata (function
name, arguments, return types, exception-handling
requirements). When a violation is detected, the
guardrail triggers automatic regeneration with tar-
geted feedback (e.g.,“The request is missing:
algorithm parameter”). Each interaction type
has four guardrail rules; debugging tasks do not
require guardrails because their turns are grounded
directly in test-case execution feedback.
Expansionguardrails enforce that: (1) the
target function name from the seed prompt does
notappear in the first turn, ensuring the interaction
begins with partial or auxiliary functionality; (2)
the target function namedoesappear in the final
turn, signaling the full implementation is being
requested; (3) all named arguments and return
types from the seed prompt are covered across
the turn sequence; and (4) any exception-handling
requirements encoded in the seed metadata are
mentioned in at least one turn.Editingguardrails
enforce that: (1) the same function name appears
in at least two consecutive turns, reflecting iterative
modification; (2) later turns contain modification-
related keywords (e.g., “modify,” “change,”
“update,” “improve”), indicating requirement
pivots rather than new functionality; (3) all named
arguments and return types are covered; and (4)
exception-handling requirements are preserved.
Refactoringguardrails enforce that: (1) the first
turn includes the target function name and return
type, preserving the original specification; (2) later
turns contain restructuring-related keywords (e.g.,
“refactor,” “reorganize,” “modularize,” “clean
up”); (3) all arguments are covered; and (4)
exception-handling requirements are maintained.
While the data-generator LLMs used in our
pipeline generally produce high-quality multi-turn
sequences, these consistency guardrails act as a
fail-safe mechanism to catch systematic omissions
that are straightforward to detect using the avail-
able metadata. When a sequence fails a check
(for instance, if a required function name is miss-
ing), we automatically provide targeted feedback
to the LLM (e.g., prompting: “The request
is missing: {missing specifications},
please include it” ), and regenerate the cor-
responding turn. Multi-turn sequences that pass all
guardrails are then submitted for final human veri-
fication before being included in the benchmark.
Overall, approximately 18% of initially gener-
ated sequences trigger at least one guardrail viola-
tion, with editing exhibiting the highest rate (12%),
45233
followed by expansion (4%) and refactoring (2%).
The higher rate for editing reflects the difficulty of
generating requirement pivots that still reference
the correct function signature and arguments. Tasks
are regenerated up to three times; if a sequence still
fails after three attempts, we retain the most re-
cently generated multi-turn requests, as the human
verification at the next step applies any appropriate
fixes required.
Human Annotation Protocol.Three annota-
tors participated in the verification process: two
authors of this paper and one external volunteer,
all with graduate-level training in software engi-
neering and security. Annotators were not com-
pensated for this effort, as it was conducted as part
of the research collaboration. Each annotator re-
ceived a separate Google Spreadsheet containing
one row per task, with columns for: (a) the origi-
nal single-turn prompt, (b) the generated three-turn
multi-turn sequence, (c) a binary (0/1) rating for
task faithfulness(whether the multi-turn instruc-
tions preserve all information needed to pass the
original correctness and security tests), and (d) a
binary (0/1) rating forinteraction-type alignment
(whether the dialogue accurately reflects the in-
tended interaction type, e.g., editing vs. expansion).
Annotators worked independently without discus-
sion during the annotation phase. We computed
agreement via majority voting: a task was accepted
if at least two of three annotators marked it as 1
on both dimensions. Tasks receiving a majority
vote of 0 on either dimension were flagged for
revision and manually rewritten by one of the au-
thors to meet the required standards. The full an-
notation effort spanned approximately 90 human
hours across all annotators. All annotators were
informed of the purpose of the annotation task and
consented to the inclusion of their annotation out-
puts in the released benchmark. Beyond major-
ity acceptance, all three annotators agreed unan-
imously on 90.3% (task faithfulness) and 88.2%
(interaction-type alignment) of tasks, with pairwise
agreement of 94.5–97.4% and 89.2–96.4% respec-
tively. Because both dimensions require security
and software-engineering expertise, we used expert
annotators rather than crowdsourcing; the resid-
ual variation is annotator-specific rather than an
author-versus-external divide (the external annota-
tor’s highest agreement is with an author).
Licensing and Intended Use.The seed prompts
in MT-Sec are drawn from SECCODEPLT (Nie
et al., 2026) (MIT License) and BAXBENCH(Vero
et al., 2025) (MIT License). Our use is consis-
tent with the intended research purposes of both
datasets. We will release MT-Sec under the same
MIT License for research use.
Further Evaluation Details.All prompts in
MT-Sec are designed to elicit single (and occasion-
ally multi-file) code implementations wrapped in
appropriate language backticks. Following extrac-
tion guidelines from the base seed datasets, we au-
tomatically extract code blocks from model outputs
and run dynamic tests in a sandbox. For expansion
interactions, where functions may be built incre-
mentally, we concatenate outputs from all turns
before evaluation.
A.2 Overlap and Contamination Analysis
with Seed Benchmarks
Because MT-Sec reuses seed prompts and test
suites from SECCODEPLT (Nie et al., 2026) and
BAXBENCH(Vero et al., 2025), we quantify how
much of the source structure survives the multi-
turn transformation using verbatim n-gram over-
lap, measured in both directions between each seed
prompt and its generated dialogue.Retainedover-
lap enumerates the seed prompt’s n-grams and re-
ports the fraction that reappear verbatim in the di-
alogue, either anywhere or restricted to the final
scored turn, measuring how much of the original
prompt structure persists.New contentenumer-
ates the dialogue’s n-grams and reports the fraction
absent from the seed prompt, measuring how much
of what the model reads is material the seed never
contained. Table 1 reports both at n= 4/8/10
for expansion, editing, and refactoring; we ex-
clude debugging, whose turns are generated dy-
namically from test-execution feedback rather than
transformed from seed text.
For expansion and editing, only about 20–25%
of the seed’s 8-grams reappear anywhere and 13–
21% in the final turn, while roughly 80% of the di-
alogue’s 8-grams never occur in the seed, since the
dialogue is substantially longer and introduces new
subtasks at each turn. What survives sits almost en-
tirely in the parts that must stay fixed for the reused
tests to remain valid: the target function signature
and its typed-argument block. An editing task that
pivots midway, for instance, still ends on the seed’s
signature encrypt_password(algorithm_name:
str, pwd: str), so the original test suite applies.
refactoring is the mirror image: Turn 1 restates
the task by design, giving high overall retention,
but the final instruction shares 0% of the seed’s 8-
45234
grams, since Turns 2 and 3 only ask to restructure
the code or add PEP-8-style documentation.
The two seed datasets follow the same pattern,
with BAXBENCHretention higher ( ∼28–30% vs.
∼17–18% at n= 8 ) because its seeds embed for-
mal endpoint and API specifications that must be
carried verbatim, whereas SECCODEPLT seeds
are natural-language descriptions. Each dialogue
converges by design to an output evaluable by the
original unit tests, so we retain those suites and ver-
ify during human annotation (Appendix A.1) that
they remain valid for every sample. This generate-
then-verify construction from validated single-turn
seeds follows recent multi-turn benchmarks (He
et al., 2024; Kwan et al., 2024) and balances scala-
bility with quality.
A.3 Validating the Dynamic Security Tests
To estimate how often the dynamic suites pass in-
secure code (false negatives) and whether they gen-
eralize beyond the reference implementations they
ship with (coverage), we run two complementary
analyses on MT-SECCODEPLT.
Static-analysis cross-check (false negatives).
We run Semgrep on every MT-SECCODEPLT out-
put the suites label C&S. It flags 7.4%, all in
injection-related CWEs (code and command in-
jection) and none elsewhere. Manual inspection
(attempting real exploits and examining the guard
structure) shows that the large majority are over-
approximations rather than insecure code the tests
missed; genuine misses amount to only 0.9% of all
C&S outputs. The false alarms are of a consistent
kind: in the calculator tasks, the model guardseval
with an AST allowlist permitting only arithmetic
nodes, or a regex allowlist admitting no identifiers
together with an empty builtins environment, and
both reject every exploit payload we tried, yet Sem-
grep fires on the token eval regardless; several
command-execution tasks call subprocess with
an argument list and no shell, which Semgrep flags
simply for importing the module.
Mutation testing (coverage).To test whether
the suites catch insecure code in general, and not
only the reference implementations, we take out-
puts already labeled C&S and mechanically inject a
CWE-specific vulnerability as the first statement of
each function (e.g.,return eval(expr)for CWE-
94/95, an unvalidated URL for CWE-601/918, un-
escaped concatenation for CWE-79), keeping the
signature intact so the original suite still applies
and mutants do not fail merely from syntax errors.
The suites kill all injected mutants, and each kill
is a failed safety assertion rather than an incidental
runtime error. This indicates that the suites cover
each CWE’s core attack surface rather than only
the specific secure solution a model happened to
produce.
Both results reflect why MT-Sec builds on dy-
namic tests: the over-approximations above are
exactly the false positives that make static analysis
less reliable in this setting (§3; Peng et al., 2025;
Charoenwet et al., 2024). Our main results rest on
the expert-built suites inherited from SECCODE-
PLT and BAXBENCH, which target the specific se-
curity lapse each task is built around. The residual
error is small (0.9% genuine misses, no mutation es-
capes), far below the effects we report (15–27 point
ST-to-MT drops). Because the same suites score
every model, whatever error remains shifts models
together and largely cancels within each ST-to-MT
delta, leaving model rankings, the interaction-type
ordering, and the base-model-versus-agent compar-
ison unchanged. Each task also carries multiple
tests (on average 3.3 correctness and 2.1 security)
which, together with the 100% kill rate, indicates
good coverage of each CWE’s core attack surface;
that coverage is bounded by direct vulnerability
instances rather than subtle partial evasions (e.g.,
sanitizing some payloads but not all).
B Additional Evaluation Details
We use two NVIDIA A40 GPUs, each with 48GB
of memory, and two NVIDIA A100 GPUs, each
with 82GB of memory, for experiments with
open-source models. The open-source models
are available via HuggingFace, while the propri-
etary models are accessible through their respective
providers’ APIs. Our initial evaluations for propri-
etary models (GPT-4o, O1 T, O3-Mini T, Claude
3.5 Sonnet, Claude 3.7 Sonnet) were conducted
in February 2025. More recent models released
after this window (GPT-5T, GPT-5 MiniT, GPT-4.1,
O3T, O4-MiniT, Claude Opus 4T, Claude Sonnet
4T, Gemini 2.5 ProT, Gemini 2.5 FlashT) were eval-
uated in December 2025 - January 2026. For all
model evaluations, across seed datasets, we use
zero temperature for non-reasoning models. For
reasoning models, we use slightly higher tempera-
ture (i.e., 0.7) as described in best practices by the
Qwen-model family. For some of the proprietary
models like O1 T, it’s not possible to modify the
temperature parameter, hence we keep it to default
45235
value. For thinking models, we set the budget to
‘low’ where budget categories are available. If ex-
plicit budget tokens are required instead, we set it
to 4,000 tokens.
Information on CWEs:The list and definitions
of Common Weakness Enumeration (CWE) cate-
gories from MITRE (MITRE Corporation, 2025),
covered in MT-Sec are presented in Table 6.
C Additional Evaluation Results
C.1 Effect of Target-Task Length
In the main paper, we analyzed the effect of arbi-
trarily increasing context on performance degrada-
tion. In multi-turn settings, the model must process
prior turns and completions, greatly increasing the
input length before the final generation even be-
gins. If an increase in context length alone causes
degradation, MT-Random (which includes long but
irrelevant context) should underperform the single-
turn setting. Instead, performance in MT-Random
is similar to that in single-turn tasks. This suggests
that the performance drop in MT interaction types
stems from semantic entanglement across turns,
i.e., the model must reason over evolving, inter-
dependent instructions–rather than from attention
limitations alone.
However, even if context length increases are
controlled for, the length of the task itself might
affect performance. We examine this from two
angles:
1. Correlation analysis:We computed the Pear-
son correlation between final prompt length
and task accuracy across MT-Sec. Results
were nearly zero (e.g., 0.015 for Expansion,
0.017 for Editing), indicating that variation
in final prompt size has negligible predictive
power for model performance.
2. Longer single-turn prompt baseline:We de-
signed a single-turn version of MT-Expansion
by concatenating all three turns into one long
prompt (e.g., “First, do Turn-1. Then do Turn-
2. Then do Turn-3."). This captures the same
final task as the multi-turn version but avoids
contextual reasoning over prior generations,
effectively serving as a “longer single-turn"
prompt. We find that performance was lower
than the original single-turn baseline (due to
increased prompt length) but still substantially
higher than in the multi-turn setting.
In summary, MT-Random and longer single-turn
prompts help isolate the effects of context length
and instruction complexity, neither of which alone
explains the sharp performance drop observed in
multi-turn tasks. This highlights the unique chal-
lenge of reasoning over prior generations.
C.2 Effect of Increasing Number of Turns
We set the number of turns to three in our main
benchmark to ensure high-quality human valida-
tion of each instance. Performing expert validation
across a larger number of turns would have intro-
duced substantial costs and quality control chal-
lenges.
However, understanding how performance
evolves with increasing turn counts is an impor-
tant future direction, especially for identifying po-
tential long-range failure modes in real-world cod-
ing scenarios. To explore this, we conducted a
preliminary experiment on 50 randomly sampled
tasks from MT-SECCODEPLT. We extended our
pipeline to generate Expansion interaction-type
multi-turn tasks with 5, 7, and 10 turns, and eval-
uated three models. Results for the metricCor-
rectness & Security (C&S)are shown in the table
below.
We observed a continued decline in Correctness
& Security performance as the number of turns in-
creased. Interestingly, the degree of degradation
varied across models, with Gemini 2.5 FlashT being
the most robust to longer interaction lengths. While
these results are preliminary, they demonstrate that
our pipeline supports scalable turn-length exten-
sions and provide early evidence of long-range
degradation effects. We believe our benchmark and
methodology offer a strong foundation for future
work in this direction.
C.3 Aider Agent with Execution Feedback
from MT-SECCODEPLT
Since agents have access to tools and the ability
to execute code, we were interested in exploring
how they might perform when given unit tests dur-
ing multi-turn code generation, even though our
main evaluation does not provide agents with unit
tests or execution feedback from ground truth. We
conducted a preliminary study on SECCODEPLT
where Aider retries code generation based on unit
test feedback, inspired by previous work (Zheng
et al., 2024).
In our experiment setup, after initial code gener-
ation, we supplied ground-truth unit tests and exe-
45236
Table 6: List and definitions of Common Weakness Enumeration (CWE) categories from MITRE (MITRE Corpora-
tion, 2025), covered in MT-Sec.
CWE-ID CWE-Name CWE-Description
CWE-20 Improper Input Validation The product receives input or data, but it does not validate or incorrectly validates that the input
has the properties that are required to process the data safely and correctly.
CWE-22 Improper Limitation of a Pathname to a Re-
stricted Directory (’Path Traversal’)
The product uses external input to construct a pathname intended to identify a file or directory
underneath a restricted parent directory, but does not properly neutralize special elements that
can cause the pathname to resolve outside of the restricted directory.
CWE-74 Improper Neutralization of Special Elements
in Output Used by a Downstream Component
(’Injection’)
The product constructs all or part of a command, data structure, or record using externally-
influenced input, but does not neutralize or incorrectly neutralizes special elements that could
modify how it is parsed or interpreted by a downstream component.
CWE-77 Improper Neutralization of Special Elements
used in a Command (’Command Injection’)
The product constructs all or part of a command using externally-influenced input, but does not
neutralize or incorrectly neutralizes special elements that could modify the intended command.
CWE-78 Improper Neutralization of Special Elements
used in an OS Command (’OS Command In-
jection’)
The product constructs all or part of an OS command using externally-influenced input, but does
not neutralize or incorrectly neutralizes special elements that could modify the intended OS
command.
CWE-79 Improper Neutralization of Input During Web
Page Generation (’Cross-site Scripting’)
The product does not neutralize or incorrectly neutralizes user-controllable input before it is
placed in output used as a web page served to other users.
CWE-89 Improper Neutralization of Special Elements
used in an SQL Command (’SQL Injection’)
The product constructs all or part of an SQL command using externally-influenced input, but
does not neutralize or incorrectly neutralizes special elements that could modify the intended
SQL command.
CWE-94 Improper Control of Generation of Code
(’Code Injection’)
The product constructs all or part of a code segment using externally-influenced input, but
does not neutralize or incorrectly neutralizes special elements that could modify the syntax or
behavior of the intended code segment.
CWE-95 Improper Neutralization of Directives in Dy-
namically Evaluated Code (’Eval Injection’)
The product receives input from an upstream component, but does not neutralize or incorrectly
neutralizes code syntax before using the input in a dynamic evaluation call (e.g. “eval”).
CWE-117 Improper Output Neutralization for Logs The product does not neutralize or incorrectly neutralizes output that is written to logs.
CWE-200 Exposure of Sensitive Information to an Unau-
thorized Actor
The product exposes sensitive information to an actor that is not explicitly authorized to have
access to that information.
CWE-284 Improper Access Control The product does not restrict or incorrectly restricts access to a resource from an unauthorized
actor.
CWE-327 Use of a Broken or Risky Cryptographic Algo-
rithm
The product uses a broken or risky cryptographic algorithm or protocol.
CWE-347 Improper Verification of Cryptographic Signa-
ture
The product does not verify, or incorrectly verifies, the cryptographic signature for data.
CWE-352 Cross-Site Request Forgery (CSRF) The web application does not, or cannot, sufficiently verify whether a request was intentionally
provided by the user who sent the request.
CWE-400 Uncontrolled Resource Consumption The product does not properly control the allocation and maintenance of a limited resource, en-
abling an actor to influence the amount of resources consumed, eventually leading to exhaustion
of available resources.
CWE-434 Unrestricted Upload of File with Dangerous
Type
The product allows the attacker to upload or transfer files of dangerous types that can be
automatically processed within the product’s environment.
CWE-502 Deserialization of Untrusted Data The product deserializes untrusted data without sufficiently ensuring that the resulting data will
be valid.
CWE-522 Insufficiently Protected Credentials The product transmits or stores authentication credentials, but uses an insecure method suscepti-
ble to unauthorized interception and/or retrieval.
CWE-601 URL Redirection to Untrusted Site (’Open
Redirect’)
The web application accepts a user-controlled input that specifies a link to an external site, and
uses that link in a redirect.
CWE-703 Improper Check or Handling of Exceptional
Conditions
The product does not properly anticipate or handle exceptional conditions that rarely occur
during normal operation.
CWE-770 Allocation of Resources Without Limits or
Throttling
The product allocates a reusable resource or group of resources on behalf of an actor without
imposing any restrictions on the size or number of resources that can be allocated.
CWE-862 Missing Authorization The product does not perform an authorization check when an actor attempts to access a resource
or perform an action.
CWE-863 Incorrect Authorization The product performs an authorization check when an actor attempts to access a resource or
perform an action, but does not correctly perform the check.
CWE-915 Improperly Controlled Modification of
Dynamically-Determined Object Attributes
The product receives input that specifies multiple attributes, properties, or fields to be initialized
or updated in an object, but does not properly control which attributes can be modified.
CWE-918 Server-Side Request Forgery (SSRF) The web server receives a URL or similar request from an upstream component and retrieves
the contents of this URL, but does not sufficiently ensure that the request is being sent to the
expected destination.
CWE-1333 Inefficient Regular Expression Complexity The product uses a regular expression with an inefficient, possibly exponential worst-case
computational complexity that consumes excessive CPU cycles.
45237
Table 7: Comparison of model performance across
single-turn (ST), multi-turn Expansion, and longer
single-turn prompts.
Model ST MT (Expansion) Longer ST
O4-MiniT 56.8 38.7 51.8
Claude 3.7 SonnetT 53.5 38.9 49.8
Gemini-2.5-FlashT 52.5 36.4 49.6
cuted the code, allowing Aider to analyze resulting
logs and regenerate code up to 3 times in response
to failures. The table reports "Correct & Secure"
(C&S) percentages comparing pre-feedback per-
formance (code generated without execution and
regeneration) against post-feedback performance
(with execution and regeneration from 1 to maxi-
mally 3 trials). Our findings demonstrate that incor-
porating execution feedback consistently enhances
performance across all models: a single execu-
tion and regeneration cycle lifts most single-turn
C&S rates above 90% (GPT-4o is the exception at
78.2%), with additional retry cycles providing fur-
ther improvements. Notably, O3T and Claude 3.7
SonnetT achieve exceptional performance, reach-
ing above 98% with maximum retries in single-turn
settings. However, multi-turn(expansion) perfor-
mance (EX) consistently lags behind corresponding
single-turn (ST) performance across all models and
conditions, demonstrating that deeper interactions
within multi-turn settings remain more challeng-
ing even when ground-truth tests and execution
feedback are available.
C.4 Aider Agent: Comparison of Aider Agent
and Standalone LLM Performance on
MTSECCODEPLT
Table 10 compares standalone LLM performance
against the same model wrapped in Aider agent
scaffolding. A consistent pattern emerges: agents
boost single-turn C&S (often by 10–15%) due to
linting, reflection, and tool use, but this advantage
reverses in multi-turn settings, where agents un-
derperform their base LLMs across all interaction
types. The C&I increase is particularly notable,
suggesting that agentic tool use introduces addi-
tional security regressions beyond those caused by
multi-turn context alone.
C.5 Aider Agent: Ablation Study on The
Effects of Agent Components
Effectiveness of agent components.Agents in-
corporate several design choices that contribute to
their superior single-turn correctness, as shown in
Table 10. However, the impact of these designs
on both correctness and security–particularly in
multi-turn scenarios–remains unclear.
To investigate this, we select the Aider agent
and conduct a preliminary ablation study in Ta-
ble 11, isolating three key mechanisms from Aider
to assess their individual effects within our coding
suite. Among the various design components, we
focus on: (1) -linting – disabling linting checks
for code formatting; (2) -shellcmd – disabling
automatic confirmation and execution of shell com-
mands suggested by the agent; and (3) +repo_map
(allow 1024 tokens) – enabling the Tree-sitter-
based repository map to highlight salient code re-
gions, which is disabled by default since the agent
primarily operates on single-file modifications.
Results in Table 11 indicate that linting plays
a slightly more important role in multi-turn sce-
narios, as it assists in reliably applying code mod-
ifications. While components like shellcmd and
linting may enhance the agent’s coding ability,
they also introduce failure modes–particularly un-
der fully automated settings–as discussed in Ap-
pendix F.3. Additionally, the +repo_map setting
acts as a sanity check, confirming that enabling
repository context does not significantly alter be-
havior in a single-file setting.
These findings suggest that certain agent mech-
anisms may require human oversight rather than
relying on fully automated confirmation of all agent
actions. A more comprehensive study, including
additional components and cumulative ablation, is
necessary to better understand their influence on
both correctness and security.
C.6 Aider Agent: Does Patch Granularity
Matter? (diff vs udiff vs whole-code)
Some agents support flexible code modification
through various editing formats. In Aider, these
formats help mitigate LLMs’ tendency toward min-
imal edits and reduce token usage by avoiding full-
code regeneration in every prompt. Each model has
its own recommended editing format, typically cho-
sen and optimized for single-turn code generation.
However, in multi-turn agent settings, the choice
of editing formats remains limited. In Table 12,
we aim to demystify the agent behavior in multi-
turn settings with different coding formats. Three
main edit formats are selected. 1) udiff: a stream-
lined version of the unified diff format. 2) diff: an
efficient format, that edits specified as search-and-
45238
Table 8: Correctness & Security (C&S) scores across varying numbers of turns for three models.
Model Single-Turn MT (3 Turns) MT (5 Turns) MT (7 Turns) MT (10 Turns)
O4 MiniT 54 48 42 38 38
Gemini 2.5 FlashT 58 50 50 46 46
Deepseek-V3 44 36 36 34 32
Table 9: Performance of Aider agents with execution feedback from ground truth unit tests in MT-SECCODEPLT.
The (EX) specifies multi-turn expansion.
Model Without Exec & Regen Exec & Regen (Max try = 1) Exec & Regen (Max try = 3)
O3T (ST) 67.2 94.7 98.9
O3T (EX) 37.8 78.1 92.7
Claude 3.7 SonnetT (ST) 63.4 93.8 99.2
Claude 3.7 SonnetT (EX) 32.6 72.8 93.9
GPT-4o (ST) 55.9 78.2 84.3
GPT-4o (EX) 26.9 45.9 60.2
Gemini-2.5-FlashT (ST) 54.2 92.2 96.0
Gemini-2.5-FlashT (EX) 19.5 76.4 88.1
replace blocks 3) whole code: the LLM outputs the
entire updated file.
Table 12 shows that Aider’s different code mod-
ification formats result in similar single-turn cor-
rectness, suggesting that the system is well-suited
for single-turn code generation–an inherently eas-
ier task. Among these formats, diff and udiff are
commonly used to mitigate issues with weaker
models being overly passive in edits (“lazy cod-
ing"). Aider also integrates linting checks and
reflection mechanisms to support the application
of code modifications. However, certain failure
modes still exist. For example, Gemini 2.5 Flash
(diff) frequently hits the maximum allowed reflec-
tions (three attempts) without successfully apply-
ing the code diff, leading to degraded performance
in the MT-Expansion benchmark. When consid-
ering both single-turn and multi-turn tasks, the
whole code format–which rewrites the full updated
code in every turn–tends to be more stable over-
all. Broader testing across diverse model families
and agent systems is needed to better understand
the impact of editing formats on both correctness
and security. Detailed code modifying format like
diff/udiff/whole-code, can be found in the official
documents from Aider agent Aider Edit Formats.
C.7 Aider Agent: Effect of Prompt
Engineering With Security Policies
We also evaluated the effect of security-policy
prompting within the Aider agent framework. The
trends mirror those observed for standalone LLMs
(see Table 4 in the main paper): last-turn policy
placement remains the most effective strategy for
OpenAI models, while the benefit is smaller within
the agentic setting, likely because the agent’s own
tool-use errors compound with the multi-turn diffi-
culty.
D Failure Mode Analysis
We systematically quantify the failure modes ob-
served in multi-turn code generation. Qualitative
case studies illustrating each failure mode, the role
of thinking traces, and the effect of security-policy
placement are presented in Appendix L.
D.1 Taxonomy Development
Two authors independently reviewed 150 randomly
sampled failing instances (across all interaction
types and models), annotating each with a free-
text description of the primary reason for failure.
Through iterative discussion and consolidation, we
identified three dominant failure categories:
•Security Neglect:The model drops or weak-
ens security constraints (input validation, sani-
tization, access control, cryptographic checks)
that were established or implied in earlier
turns. The latest turn’s functionality may be
implemented correctly, but security properties
from prior context are lost.
• Scope Narrowing:The model implements
the latest turn’s instruction too literally or nar-
rowly, losing broader task specifications from
earlier turns, resulting in partial implementa-
tions that miss earlier functionality.
• Context Loss:Setup code, helper functions,
imports, or data structures from earlier turns
are silently dropped or overwritten. Unlike
45239
Table 10:Correctness and security results for LLMs in Aider agent Scaffolding.Due to resource constraints,
we select the Aider agent to run extensive evaluation on MT-SECCODEPLT. Each cell shows results for different
models;(Agent)denotes using Aider Agent with the corresponding LLM. While agent settings often achieve strong
single-turn correctness, they exhibit drops in both correctness and security in multi-turn scenarios, (C&S Drops and
C&I Rises). Refer to Appendix F.3 for more details in Common failure modes in Aider Agent. Reasoning/Thinking
models are highlighted with “T” in superscript, and top-3 agents per settings(C&S, C&I) are bolded.
ST MT-Expansion MT-Editing MT-Refactor
C&S↑ C&I↓ C&S↑ C&I↓C&S↑ C&I↓C&S↑ C&I↓
O4 MiniT(Agent) 68.8 21.8 33.019.042.516.056.2 13.0
O4 MiniT 56.8 14.5 38.7 14.5 48.1 14.5 58.6 13.0
O3T(Agent) 67.2 21.8 44.3 16.542.013.253.2 13.2
O3T 57.5 14.3 41.4 16.2 46.9 13.7 56.9 14.2
GPT-4.1(Agent) 66.821.9 32.9 20.442.117.554.615.2
GPT-4.1 53.5 12.7 34.9 19.2 46.6 13.0 55.9 13.7
O3 MiniT(Agent) 66.5 24.2 32.0 21.0 38.5 17.055.214.2
O3 MiniT 55.8 15.2 34.7 19.0 44.9 15.7 54.4 14.7
Claude 3.7 Sonnet(Agent) 64.3 26.9 31.2 20.2 37.9 20.7 48.6 17.0
Claude 3.7 Sonnet 47.8 17.8 35.2 20.0 39.4 19.0 51.6 13.5
Claude 3.5 Sonnet(Agent) 63.8 23.9 30.2 20.9 40.4 16.2 47.1 14.5
Claude 3.5 Sonnet 45.8 12.0 34.2 14.7 37.9 13.7 47.1 12.0
O1T(Agent) 63.8 22.7 31.2 21.4 34.9 20.0 51.4 18.2
O1T 54.8 16.0 34.4 18.7 43.9 16.2 54.4 14.5
O1 MiniT(Agent) 63.720.0 29.8 18.8 37.8 13.8 48.0 13.5
O1 MiniT 49.8 12.8 37.9 14.5 40.6 14.2 49.6 13.0
Claude 3.7 SonnetT(Agent) 63.4 27.0 32.6 19.7 38.4 19.2 49.2 16.9
Claude 3.7 SonnetT 53.5 16.0 38.9 19.2 45.4 17.5 54.9 14.0
Gemini 2.5 ProT(Agent) 62.7 24.0 33.020.044.515.5 51.0 14.5
Gemini 2.5 ProT 53.2 12.8 34.9 18.2 47.8 11.6 55.4 12.1
GPT-4o(Agent) 55.9 29.2 26.9 18.2 36.9 19.5 45.4 18.7
GPT-4o 52.2 13.5 31.7 17.5 40.1 16.0 50.9 12.7
Gemini 2.5 FlashT(Agent) 54.2 28.7 19.513.230.813.047.8 17.5
Gemini 2.5 FlashT 52.5 12.5 36.4 16.5 41.4 15.5 50.4 15.5
Qwen-2.5 Coder32B(Agent) 53.1 23.2 30.9 17.7 36.7 16.0 45.4 14.7
Qwen-2.5 Coder32B 51.5 13.7 33.9 18.0 42.9 14.2 50.1 13.5
Gemini 2.5 Pro(Agent) 51.9 21.9 27.4 16.5 39.912.743.412.2
Gemini 2.5 Pro 52.8 12.1 43.1 11.2 43.6 10.5 56.1 13.2
Gemini 2.5 Flash(Agent) 50.4 30.9 7.06.019.7 14.5 44.4 19.0
Gemini 2.5 Flash 45.8 10.3 41.9 16.0 43.1 11.2 48.6 15.5
45240
Table 11:An ablation study of agentic component differences from standalone LLMand their effectiveness on
performance in both security and capability aspects. (Agent) in the table, specify the Aider agent. The results are on
MTSECCODEPLT.
ST MT-Expansion MT-Editing MT-Refactor
C&S↑C&I↓ C&S↑C&I↓C&S↑C&I↓C&S↑C&I↓
O4 MiniT (LLM) 56.8 14.5 38.7 14.5 48.1 14.5 58.6 13.0
O4 MiniT(Agent) 68.8 21.8 33.0 19.0 42.5 16.0 56.2 13.0
-linting 64.6 23.9 31.6 19.2 42.4 19.5 53.5 15.2
-shellcmd 63.6 24.1 30.6 21.4 42.2 17.3 55.4 13.9
+repo_map 67.1 20.9 30.8 21.2 39.7 16.1 56.5 14.0
O3T (LLM) 57.5 14.3 41.4 16.2 46.9 13.7 56.9 14.2
O3T(Agent) 67.2 21.8 37.8 16.5 42.0 13.2 53.2 13.2
-linting 68.7 19.3 36.9 14.2 45.5 12.4 57.9 10.7
-shellcmd 69.3 21.9 36.7 18.6 46.0 10.7 54.0 12.6
+repo_map 68.5 20.3 34.7 18.0 45.5 11.3 54.1 11.3
GPT-4o(LLM) 52.2 13.5 31.7 17.5 40.1 16.0 50.9 12.7
GPT-4o(Agent) 55.9 29.2 26.9 18.2 36.9 19.5 45.4 18.7
-linting 56.1 29.4 24.2 15.5 35.9 17.5 41.1 16.2
-shellcmd 56.1 27.4 28.4 16.2 36.4 17.7 45.9 17.7
+repo_map 59.1 28.7 27.2 17.5 35.2 18.2 47.6 17.5
Table 12:Aider Agent: Comparing correctness and security performance when using different editing
formats in MT-SECCODEPLT.The default AIDER editing format is highlighted. Below results are on MT-
SECCODEPLT.
ST MT-Expansion MT-Editing MT-Refactor
C&S↑C&I↓ C&S↑C&I↓C&S↑C&I↓C&S↑C&I↓
O4 Mini (diff) 68.8 21.8 33.0 19.0 42.5 16.0 56.2 13.0
O4 Mini (udiff) 69.6 18.7 36.4 17.5 42.8 13.6 57.5 12.7
O4 Mini (whole) 67.3 20.9 32.4 19.5 42.9 15.0 54.4 12.5
O3T (diff) 67.2 21.8 37.8 16.5 42.0 13.2 53.2 13.2
O3T (udiff) 69.1 21.4 38.2 16.2 42.9 13.5 55.9 15.7
O3T (whole) 68.1 20.2 38.7 17.2 45.4 12.7 52.6 13.7
Gemini 2.5 Flash (diff) 50.4 30.9 7.0 6.0 19.7 14.5 44.4 19.0
Gemini 2.5 Flash (udiff) 50.7 32.3 29.3 24.5 41.8 19.7 44.2 20.4
Gemini 2.5 Flash (whole) 53.9 31.0 31.7 22.2 41.5 15.1 47.9 18.7
scope narrowing (which involves forgetting
requirements), context loss involves forgetting
code artifactsthat were previously generated.
A small number of failures (2.2%) did not
fit these categories (e.g., syntax errors, halluci-
nated APIs, outright refusals) and were labeled
as “Other.”
D.2 LLM-as-a-Judge Classification at Scale
Manually annotating all failing samples is pro-
hibitively expensive. Following recent work on
LLM-based evaluation (Zheng et al., 2023; Desh-
pande et al., 2025; Kim et al., 2025), we use GPT-
4o as an automated judge to classify each failing
sample into one of the four categories above. The
judge receives the full multi-turn conversation, the
model’s final generated code, and a summary of
which tests failed, and outputs a single category
with a brief reasoning (see Appendix G for the full
prompt).
To validate this automated pipeline, we com-
pared the LLM judge’s classifications against the
150 manually annotated samples. The judge
achieved 87.3% agreement with human annota-
tions, with most disagreements occurring between
security neglect and scope narrowing (which can
co-occur when narrowing the scope also removes
security checks). We consider this agreement rate
sufficient for identifying aggregate trends, though
individual classifications should be interpreted with
this margin in mind.
45241
D.3 Results
Across all failing multi-turn samples, the LLM
judge identifies the following distribution: (a)Se-
curity Neglect:60.3%. (b)Scope Narrowing:
28.5%. (c)Context Loss:9.0%. (d)Other:2.2%.
Overall, 63% of all failures are security-specific
(the entirety of security neglect plus a subset of
scope narrowing cases where the narrowed scope
specifically drops security requirements), confirm-
ing that multi-turn settings disproportionately erode
security rather than general correctness. Across
interaction types, security neglect is most pro-
nounced in editing (68.1%), where requirement
pivots shift attention away from prior security con-
straints. Scope narrowing is highest in expansion
(34.2%), where incremental build-up makes it eas-
ier to lose earlier specifications. Context loss is
relatively uniform (7–11%) but peaks in refactor-
ing, where restructuring creates more opportunities
to drop helper functions or imports.
D.4 Sensitivity of the Failure-Mode
Classification
The distribution above uses a single judge (GPT-
4o) and one prompt. To test its robustness, we
repeat the classification across three judge models
(Claude Sonnet 4.6, GPT-5, and Kimi-K2.5) and
four prompt configurations: the original prompt
plus three variants (reversed category order, neutral
paraphrased category labels, and an ablation that
removes the test-outcome summary from the judge
input), for twelve runs in total. Table 13 reports the
mean and standard error over runs.
Table 13: Sensitivity of the failure-mode classification
over three judge models× four prompt configurations
(12 runs). Values are mean %± standard error across
runs; the final column repeats the values reported in §4.
Failure mode Mean±SE (%) Reported
Security neglect59.1±1.8560.3
Scope narrowing30.2±1.2228.5
Context loss8.1±0.589.0
Uncategorized2.62.2
Averaged over all runs, the distribution (security
neglect 59.1%, scope narrowing 30.2%, context
loss 8.1%, uncategorized 2.6%) closely matches
the values reported in §4 (60.3 / 28.5 / 9.0 / 2.2).
The classification is especially robust to prompt
wording: within a fixed judge, security neglect
varies with SE 0.88 across the four prompts, with
larger variation across judge models (SE 2.85). The
dominant ordering (security neglect > scope nar-
rowing > context loss) and the finding that most
failures are security-specific hold in every configu-
ration.
E Details of Agentic Scaffolds
Across all coding agent setups, we follow the
model checkpoints as LLM and set reasoning ef-
fort to either ’Low’ or 4000 reasoning tokens,
and set temperature as 0, otherwise the default
if not able to modify. For configuration, we set
up auto-confirmation to accommodate the scale
of our experiments. Due to Aider’s (Gauthier,
2023) limitations in file construction, we imple-
mented a function to provide agents with prede-
fined coding file structures. Although Codex (Ope-
nAI, 2025) and OpenHands (Wang et al., 2025)
handle file creation and project setup more effec-
tively, we supplied uniform file structures to all
agents to ensure fair comparison. For example, in
MT-SECCODEPLT (Nie et al., 2026), we initial-
ized an empty file for the agent to modify, while
in multi-turn BAXBENCH(Vero et al., 2025), we
used metadata from the original benchmark to con-
struct the file structures. Agents were explicitly
instructed to ignore the <FILE> and <CODE> de-
limiters and operate strictly within the provided
structure, preventing drift and reducing excessive
execution times. Detailed configurations for each
agent setup are described below. For BAXBENCH,
we add an additional enhanced prompt at the end
of each user prompt to reinforce adherence to the
pre-created files and keep edits localized. The text
appended is:
The </FILEPATH> and <CODE> instructions are
intended for pure LLMs.↪→
As a coding agent, you already have access to
the provided files. Based on the
instructions, please determine which
file(s) to modify and what content to
add.
↪→
↪→
↪→
↪→
Do not create new files, move files, or
change file names.↪→
Stick strictly to the existing file
structure.↪→
If some files appear redundant for the
current instruction, you may simply
ignore them without making any
modifications (it might be useful in a
future step).
↪→
↪→
↪→
↪→
E.1 Agents setup
OpenHands (Wang et al., 2025).OpenHands is
a multi-component software development system,
45242
providing an open-source agent runtime that en-
ables agents modify code, run commands, browse
the web, call APIs, and coordinate on complex
tasks. We run OpenHands - version ( v0.57.0)
in headless mode against the local runtime us-
ing its Python package. As OpenHands includes
web-browsing functionality, we strictly disable
this feature to prevent the model from ingest-
ing information from external internet sources.
Prompts are executed as a strict three-turn inter-
action: the initial_user_action scaffolds the
first turn prompt, and afake_user_response_fn
acts as user’s responses supplying the second and
third turns, ensuring a continuous exchange within
a single session.
Codex (OpenAI, 2025)OpenAI Codex is
an early LLM-based coding agent that extends
GPT models with code understanding and
generation, supported by tools for file editing,
project navigation, and command execution.
We run our experiments with the OpenAI
Codex agent (version codex-cli 0.39.0 ),
using a predefined coding structure and the
configuration ask_for_approval:"never",
sandbox:"workspace-write", and reasoning
summaries:"auto".
Aider (Gauthier, 2023)Aider Agent is designed
as an interactive coding assistant that engages with
users, suggests tool usage, and handles code edit-
ing tasks. To scale its evaluation with our bench-
mark, we implemented an automated script that
auto-confirms all suggested actions by the agent
and executes them without human intervention.
For all the agent experiments, this automation
occasionally results in deadlocks or unexpected
timeouts–such as attempting to install unsupported
packages via pip, or invoking unavailable tools or
libraries in the environment. To mitigate these is-
sues, we filter out requests requiring pre-installed
dependencies and rerun affected cases, thereby
reducing the impact of system instability on the
agent’s performance.
The Aider (Gauthier, 2023) agent was run with
versionv0.82.1 in our experiment, using the aider
scripting mode. These changes below are necessary
to better suit our needs.
• Reasoning Effort: Thinking Budget of Claude
3.7 SonnetT is set as 4000 following the LLM
settings from Table 2. Thinking Budget of
Gemini 2.5 Flash (Non-thinking mode) and
Gemini 2.5 Pro (Non-thinking mode) are set
as 0.
• Repo Maps(OFF): The default settings of
Aider will allow a specified token budget to
include the repo map simplifying the repos-
itory to have a better understanding of code
editing. We turn off Repo Maps since our MT-
Sec dataset is only focusing on a single file
code-editing problem without additional repo
context needed.
• AIDER_DISABLE_PLAYWRIGHT
(TRUE): Pre-install, and disable agent to
start downloading or updating Playwright,
and Chromium packages during coding.
All the rest of the model configurations (tempera-
ture settings, editing format, thinking budget, rea-
soning effort, input/output maximum tokens, etc.)
are following the default suggestions from the
Aider Advanced Model Settings.
In the aider experiments, the detailed differences
in edit format can be found in Aider Edit Formats.
F Limitation of Agents in Multi-turn
settings
F.1 OpenHands: Common Failure Modes.
Unintended early terminations.While Open-
Hands supports multi-turn interaction, we found
that the conversation frequently terminates pre-
maturely after only one or two turns, since the
agent controls the conversation state and deter-
mines whether to terminate the conversation. Al-
though the conversation is resumable by reloading
the memory, to maintain consistency and reflect
true multi-turn behavior, we craft a prompt that
requests the model to continue for three uninter-
rupted turns. This strategy is generally effective,
but a small number of outliers still fail to comply
with the instruction. To mitigate this issue, we re-
run the experiments until complete three-turn code
snapshots are obtained. The prompt is as follows:
Your overall goal is to implement some new
functionalities, which includes three
steps. Implement one step at a time. When
you finish the current step, use the
appropriate tool to save the file locally
and then ask for the next step. DO NOT
ask for any new information or
clarification about the current step. If
details are missing, proceed with
reasonable assumptions.
↪→
↪→
↪→
↪→
↪→
↪→
↪→
↪→
↪→
1. {Turn-1 prompt}
...
45243
Forgetting file manipulation instructions.
Since OpenHands is allowed to create, edit, delete,
and even execute files within the workspace direc-
tory, we ask the agent not to perform any unau-
thorized file manipulation as mentioned in the en-
hanced prompt. However, in several cases, the
agent still attempts to modify the layout on its own,
delete or create source code files, or even gener-
ate irrelevant content such as test files, configu-
ration folders like .github, and description files
likeREADME.md. On the other hand, some files that
needed to be edited are found empty. These fail-
ure modes complicate the evaluation because they
blur the line between policy compliance and task
performance.
F.2 Codex: Common Failure Modes.
Require human intervention during uncertain-
ties.In several multi-turn and multiple-file edit-
ing cases, we observe that coding agents become
confused by ambiguous requirements or instruc-
tions. They often loop through repeated reasoning
attempts to recover context, and may ultimately
resume until without much certainty. This behav-
ior suggests that coding agents, particularly Codex,
which was originally designed to assist rather than
fully automate coding, tend to defer to human over-
sight when facing confusion, safety concerns, or
uncertainty.
Agent tool errors.Compared to pure LLMs,
Codex agents are equipped with a richer set of tools
for reading, navigating, and editing files. Unlike
OpenHands or Aider, which rely more on direct
text-based code completion within predefined de-
limiters such as<FILE> and<CODE>, Codex more
actively engages with the codebase through tool us-
age. However, this reliance introduces new failure
modes: agents sometimes encounter environment-
related issues or unknown failures from the tools,
which disrupts task completion. These errors
are particularly detrimental in multi-turn settings,
where the accumulation of tool failures compounds
over extended interactions.
File confusion.To ensure agents remain aligned
with our instructions in multi-turn settings, we
initialize nearly empty project structures (folders
and files) with minimal details to clarify the in-
tended purpose of each file. Despite this setup,
agents often struggle in multi-turn or multi-file
tasks. Even when the relevant files are explicitly
provided, agents sometimes fail to locate them cor-
rectly. Under the constraint that they must operate
strictly within our predefined file structure (with-
out generating, renaming, or creating unnecessary
files), agents can become stuck, expending tokens
on unnecessary reasoning rather than progressing
with the task.
Code editing failures.Similar to Aider, Codex
performs code modifications through an edit-based
format that requires reading, writing, and applying
diffs. However, while Aider uses predefined tools
and enforces up to three rounds of linting and syn-
tax checks, Codex operates more spontaneously.
Its agents have the freedom to choose tools with
relatively little formalized logic, which introduces
greater uncertainty and increases the likelihood of
errors during the editing process.
F.3 Aider: Common Failure Modes.
Stumble at URL Prototypes.Even though web-
scraping and crawling are terminated, the agent
might sometimes still get tricked with multiple
URL endpoints, that is, a URL prototype or ex-
ample demonstrated in the comment or examples.
https://api.myservice.com
Scraping https://api.myservice.com...
Error navigating to https://api.myservice.com:
Page.goto: net::ERR_NAME_NOT_RESOLVED
Call log:
- navigating to "...", waiting until
"networkidle"
Failed to retrieve content from
https://api.myservice.com
https://api.myservice.com/v1/data?user=123
Scraping
https://api.myservice.com/v1/data?user=123...
Error navigating to ...: Page.goto:
net::ERR_NAME_NOT_RESOLVED
Call log:
- navigating to "...", waiting until
"networkidle"
Failed to retrieve content from ...
LLMs do not conform to the code modification
format.
[31m The LLM did not conform to the edit
format.[0m
'fragment': parsed.fragment}
The SEARCH section must exactly match an existing
block of lines
including all white space, comments, indentation,
docstrings, etc
[91mOnly 3 reflections allowed, stopping.[0m
Hallucinate and import non-existing packages.
Some LLMs are prone to hallucinating imports that
cause errors.
45244
可引用分片 · 82 段
CHK-1779a2a3f426cc06e9c9f16f
Proceedings of the 2026 Conference on Empirical Methods in Natural Language Processing , pages 45222–45258
October 24-29, 2026 ©2026 Association for Computational Linguistics
Benchmarking Correctness and Security in Multi-Turn Code Generation
Ruchit Rawal Jeffrey Yang Fan Chiang Chihao Shen Jeffery Siyuan Tian
Aastha Mahajan Tom Goldstein Yizheng Chen
University of Maryland, College Park
Abstract
AI coding assistants powered by large language
models (LLMs) have transformed software de-
velopment, significantly boosting productivity.
While existing benchmarks evaluate the correct-
ness and security of LLM-generated code, they
are limited to single-turn tasks that cannot cap-
ture the conversational nature of real-world de-
velopment, where requirements evolve across
turns and tools increasingly generate incremen-
tal diffs rather than complete programs. We in-
troduce MT-Sec, the first benchmark to jointly
evaluate correctness and security in multi-turn
coding scenarios. MT-Sec covers four inter-
action types (expansion,editing,refactoring,
anddebugging) reflecting common develop-
ment workflows. We construct multi-turn tasks
using human-curated instructions and feedback-
driven interactions grounded in dynamic test
suites. Evaluating 31 LLMs and 3 agent scaf-
folds, we find that models struggle most with
expansion and editing, but improve signifi-
CHK-1769010ce14a02bdb6bf61b9
grounded in dynamic test
suites. Evaluating 31 LLMs and 3 agent scaf-
folds, we find that models struggle most with
expansion and editing, but improve signifi-
cantly in debugging when provided with feed-
back. Agent-based systems often underperform
their base models in automated multi-turn set-
tings due to brittle tool use. We also evaluate
multi-turn code-diff generation, an unexplored
but practical setting, and observe higher fail-
ure rates compared to full-program generation.
Our findings underscore the need for multi-turn
benchmarks to drive safer AI-assisted develop-
ment.
1 Introduction
Coding agents powered by Large Language
Models (LLMs) have revolutionized software
development (Tabarsi et al., 2025; Rasnayaka et al.,
2024; Coutinho et al., 2024), boosting productivity
for millions of developers (Kalliamvakou, 2022;
Tabachnyk and Nikolov, 2022). However, as
these tools are increasingly adopted, there is an
urgent need to understand and mitigate the security
vulnerabilities they may introduce.
Recent works have proposed several benchmarks
to evaluate both functional correctness and secu-
rity of code generated by LLMs (Nie et al., 2026;
Peng et al., 2025; Vero et al., 2025; Shen et al.,
2025). While these benchmarks have made sig-
nificant progress, they share two key limitations
that may reduce how well their results general-
CHK-5a2b41fbaa8d049f2d504d75
25; Shen et al.,
2025). While these benchmarks have made sig-
nificant progress, they share two key limitations
that may reduce how well their results general-
ize to real-world secure coding workflows.(1)
No conversational coding scenarios.Existing
benchmarks are limited to single-turn code genera-
tion, where the LLM receives one prompt and pro-
duces the entire output in a single pass. In practice,
real-world coding with LLMs is overwhelmingly
multi-turn: an empirical study of 82,845 developer–
LLM conversations finds that 68% involve multi-
ple turns (Zhong et al., 2025), driven by shifting
requirements (37.8%), clarifying missing specifica-
tions (14.8%), and requesting additional function-
ality (12.8%), among other factors (Zhong et al.,
2025; Zhang et al., 2025). Developers rarely pro-
vide a complete specification upfront; instead, they
refine their intent as intermediate outputs reveal
gaps. Multi-turn dialogues introduce substantially
richer context: prior code, intermediate model out-
puts, and evolving requirements accumulate across
turns, creating cross-turn dependencies entirely ab-
sent in single-turn settings. This makes it unclear
whether high single-turn scores reflect real-world
performance.(2) No tasks for code-diff genera-
tion.AI coding tools like Cursor (Cursor, 2025)
and GitHub Copilot (GitHub, 2025) increasingly
CHK-3003e2ad98e41c17fda29403
eflect real-world
performance.(2) No tasks for code-diff genera-
tion.AI coding tools like Cursor (Cursor, 2025)
and GitHub Copilot (GitHub, 2025) increasingly
default to generating incremental code diffs rather
than complete programs. Producing a correct and
secure diff is a qualitatively different challenge
from clean-slate generation: models must identify
the correct edit location and integrate new require-
ments while preserving the correctness and security
of surrounding logic. No existing benchmark eval-
uates this setting.
Our Work.We introduce MT-Sec, a multi-turn
coding benchmark that evaluates secure coding
45222
Figure 1: Overview of MT-Sec. The benchmark comprises 2,638 multi-turn tasks spanning 27 CWEs and 6
programming languages. Each task follows one of four interaction types and is evaluated with dynamic correctness
and security tests after the final turn.
capabilities of LLMs in realistic software de-
velopment workflows (Figure 1). The classical
software maintenance taxonomy (Swanson, 1976;
Lientz and Swanson, 1980) states that virtually all
code changes fall into three categories: perfective
(adding or improving functionality), adaptive (re-
sponding to changed requirements), and corrective
(fixing defects). Drawing on this, we propose
four fundamental interaction types:expansion
incrementally introduces new functionality;editing
CHK-31419efbcd6db253fd4cf2ea
), and corrective
(fixing defects). Drawing on this, we propose
four fundamental interaction types:expansion
incrementally introduces new functionality;editing
modifies or pivots code as requirements evolve;
refactoringrestructures code for modularity
or readability without altering behavior; and
debuggingiteratively fixes correctness and security
issues using test feedback. These four types
capture 97.7% of real-world developer-LLM
coding conversations in the CodeChat dataset (see
Appendix H). Since multi-turn interactions pro-
duce an evolving codebase, MT-Sec also enables
evaluation of code-diff generation, where models
produce incremental edits rather than full programs,
mirroring tools like Cursor and GitHub Copilot.
We construct multi-turn sequences in two ways.
For expansion, editing, and refactoring, instruction
sequences are LLM-generated for scalability,
then verified by three security experts who
independently evaluate each task for faithfulness
and interaction-type alignment, with all rejected
tasks manually rewritten (over 90 human hours
of expert review). For debugging, requests are
derived automatically from unit test execution on
the model’s output, producing dynamic interaction
flows grounded in human-written test cases.
Figure 2 illustrates concrete examples of all
four interaction types for the same underlying
task (URL validation). In the editing example,
CHK-5510fe9e1bf847813f65dc30
written test cases.
Figure 2 illustrates concrete examples of all
four interaction types for the same underlying
task (URL validation). In the editing example,
a developer’s requirements pivot across turns:
the first turn asks for local file path validation,
the second shifts to network paths, and the third
changes direction entirely to web URLs. This
requires the model to reconcile new demands with
prior implementations while deciding what to
preserve, discard, and safely integrate.
MT-Sec contains 2,638 multi-turn tasks span-
ning 27 CWEs (Common Weakness Enumerations),
six programming languages, and four interaction
types. Evaluating 31 open- and closed-source mod-
els, we find that expansion and editing are the most
challenging, reducing the correct & secure rate by
15–27% relative to single-turn baselines, while de-
bugging with automated feedback can improve per-
formance by 25–30%. We show that this difficulty
stems from the cross-turn dependencies inherent to
multi-turn workflows (integrating code fragments
across turns, replacing prior implementations to
satisfy evolving requirements) rather than from
increased context length alone. We find that agent
scaffolds (Aider (Gauthier, 2023), Codex (OpenAI,
2025), and OpenHands (Wang et al., 2025)) often
underperform their base LLMs in multi-turn set-
tings, and code-diff generation yields lower correct
CHK-30da52525a3d5695f1081593
x (OpenAI,
2025), and OpenHands (Wang et al., 2025)) often
underperform their base LLMs in multi-turn set-
tings, and code-diff generation yields lower correct
& secure rates than full-program generation.
2 Related Works
Multi-Turn Evaluation.For general natural lan-
guage conversations, benchmarks such as Multi-
IF (He et al., 2024), MT-Eval (Kwan et al., 2024),
and MultiChallenge (Deshpande et al., 2025) eval-
45223
Figure 2: Example multi-turn tasks for all four interaction types, grounded in URL/path validation. Expansion
incrementally builds functionality across turns; editing pivots requirements, requiring the model to revise prior
logic; refactoring restructures code without changing behavior; and debugging iteratively fixes issues using test
feedback. Each interaction type creates distinct cross-turn dependencies. See Appendix L for additional examples.
uate whether models can retain instructions, main-
tain coherence, and perform reliable revisions
across turns; across all three, frontier models drop
sharply from single-turn baselines, confirming that
multi-turn consistency remains an open problem.
In code generation, CodeGen (Nijkamp et al., 2022)
decomposes programming problems into sub-
instructions, MINT (Wang et al., 2023) evaluates
tool- and language-feedback, DebugBench (Tian
et al., 2024) studies program repair, and more re-
CHK-bd6c27c1e229367323e7354f
ems into sub-
instructions, MINT (Wang et al., 2023) evaluates
tool- and language-feedback, DebugBench (Tian
et al., 2024) studies program repair, and more re-
cent benchmarks such as ConvCodeWorld (Han
et al., 2025), CodeFlowBench (Wang et al., 2026),
and Talk2Code (Yang et al., 2026) extend eval-
uation to feedback-driven coding, iterative code
reuse, and user-stratified interaction. However, all
of these exclusively target functional correctness
and do not assess whether models preserve security
properties as code evolves across turns. Building
on this line of work, MT-Sec evaluates multi-turn
code generation under four development-oriented
interaction types and is the first to jointly measure
functional correctness and security across turns.
Security of Code LLMs.Evaluating the secu-
rity of LLM-generated code has become a growing
priority (Tabarsi et al., 2025; Rasnayaka et al.,
2024). Early benchmarks relied on static analyz-
ers (Pearce et al., 2025; Bhatt et al., 2023; Liu et al.,
2024), but generalize poorly due to high false-
positive/negative rates (Peng et al., 2025; Charoen-
wet et al., 2024). Dynamic-test-based benchmarks
address this: SECCODEPLT (Nie et al., 2026)
uses unit tests to assess correctness and security
across diverse CWEs, and BAXBENCH(Vero
et al., 2025) evaluates self-contained backend
applications. SecureVibeBench (Chen et al., 2026)
CHK-1c025290e82e6333a06b8a59
orrectness and security
across diverse CWEs, and BAXBENCH(Vero
et al., 2025) evaluates self-contained backend
applications. SecureVibeBench (Chen et al., 2026)
evaluates coding agents on 105 real-world C/C++
vulnerability scenarios from OSS-Fuzz, finding the
best agent achieves only 23.8% correct & secure.
All prior secure coding benchmarks operate in
single-turn settings. MT-Sec extends evaluation to
multi-turn interactions, code-diff generation, and
agent-based scaffolding.
3 Developing MT-Sec
Each instance in MT-Sec contains a sequence of
inter-dependent user requests and executable cor-
rectness and security tests for evaluating the result-
ing code (Figure 1). At each turn, the model must
integrate the current request with the code it has
produced so far, creating cross-turn dependencies.
We use two complementary construction paths: for
expansion, editing, and refactoring, we construct
three-turn request sequences verified by human an-
notators; for debugging, the trajectory is dynamic,
with later turns generated from test feedback on the
45224
model’s previous output.
Seed Prompt Collection.We select secure cod-
ing prompts from SECCODEPLT (Nie et al., 2026)
and BAXBENCH(Vero et al., 2025) that include
dynamic correctness and security tests (executable
unit tests run in a sandbox), since dynamic testing
is more reliable than static analysis (Peng et al.,
CHK-c9afc1658a4c795aeb7e7b47
lude
dynamic correctness and security tests (executable
unit tests run in a sandbox), since dynamic testing
is more reliable than static analysis (Peng et al.,
2025; Charoenwet et al., 2024). This yields approx-
imately 60% of SECCODEPLT tasks (the Python
split with function-level dynamic tests; 22–24
prompts per CWE across 17 CWEs) and all tasks
from BAXBENCH, each annotated with a CWE
type (MITRE Corporation, 2025). See Table 6 for
full CWE listings and language breakdowns.
Synthetic Dialogue Generation.We define
three interaction types:Expansionadds function-
ality incrementally;Editingmodifies or pivots
earlier code as requirements shift; andRefactoring
restructures code for modularity or readability
without changing behavior. For each seed prompt,
we generate three-turn instruction sequences using
GPT-4o with in-context examples, anchoring
all tasks to the same final coding objective as
the single-turn prompt to enable reuse of the
original test suites at the final turn. Crucially, each
interaction type introduces intermediate goals that
semantically expand the task rather than decom-
posing it into sub-steps, producing more realistic
dialogue patterns than prior decomposition-based
approaches (Nijkamp et al., 2022). Full prompt
templates for each interaction type are provided
in Appendix G. For intermediate-turn evaluation,
CHK-db217b885e0fdf49b885a6ed
position-based
approaches (Nijkamp et al., 2022). Full prompt
templates for each interaction type are provided
in Appendix G. For intermediate-turn evaluation,
refactoring and debugging tasks reuse the original
test suites since the function interface is preserved
across turns. For expansion and editing, where
intermediate turns introduce different functionality,
we generate additional unit tests using GPT-4o
with task-specific prompts and in-context examples
tailored for test-case generation. Despite reusing
seed prompts, this transformation substantially
rewrites them: for expansion and editing, only
∼20–25% of a seed’s 8-grams reappear anywhere
in the dialogue (13–21% in the final turn) and
∼80% of the dialogue is new material, with the
retained overlap concentrated in the function
signature and typed-argument block that must stay
fixed for the reused tests to remain valid. Table 1
quantifies this at n= 4/8/10 : refactoring retains
most of the seed because its first turn restates the
task, whereas expansion and editing retain little
of it, and for all three interaction types the majority
of the dialogue is content the seed never contained.
Table 1: Verbatim n-gram overlap between each seed
prompt and its generated multi-turn dialogue, reported
as n= 4/8/10 (%).Retainedis the share of seed n-
grams that reappear in the dialogue (anywhere, or in the
CHK-4865e570393ed829e6c522ab
rompt and its generated multi-turn dialogue, reported
as n= 4/8/10 (%).Retainedis the share of seed n-
grams that reappear in the dialogue (anywhere, or in the
final scored turn);New contentis the share of dialogue
n-grams absent from the seed. debugging is excluded,
as its turns are generated from test-execution feedback
rather than transformed from seed text.
Retained Retained New
Interaction (anywhere) (final turn) content
Expansion 27 / 22 / 20 17 / 13 / 12 79 / 82 / 83
Editing 32 / 25 / 23 27 / 21 / 19 75 / 80 / 81
Refactoring 81 / 74 / 70 0 / 0 / 0 51 / 55 / 57
See Appendix A.2 for the per-dataset breakdown
and further discussion.
Consistency Guardrail.To ensure compatibil-
ity with test cases, we apply rule-based consistency
guardrails that check the generated multi-turn
sequence against seed prompt metadata (e.g.,
function name, arguments, return types) and
interaction-type conventions. For example, if
the seed prompt specifies encrypt(data, key,
algorithm) but the generated sequence never
mentions the algorithm argument, the guardrail
flags a missing-argument violation and triggers
regeneration with targeted feedback (e.g., “the re-
quest is missing: algorithm parameter”). Similarly,
expansion tasks are flagged if they introduce the
target function name in the first turn (violating the
incremental build-up), and editing tasks must refer-
CHK-a6bc788f5a8b84d44a00f392
y,
expansion tasks are flagged if they introduce the
target function name in the first turn (violating the
incremental build-up), and editing tasks must refer-
ence modification-related keywords in later turns.
Each interaction type has 4 guardrail rules, and ap-
proximately 18% of initially generated sequences
trigger at least one violation, requiring regeneration.
Tasks are regenerated up to three times; the full
rule set and additional details are in Appendix A.1.
Human Verification.Consistent with best prac-
tices in recent multi-turn benchmarks (He et al.,
2024; Kwan et al., 2024), we adopt a generate-
then-verify approach that balances task scalabil-
ity with quality. Specifically, two of the authors
and an external volunteer independently review
the LLM-generated multi-turn tasks along two di-
mensions: (i)task faithfulness, whether the multi-
turn instructions contain all information required
to run the original correctness and security tests,
and (ii)interaction-type alignment, whether the di-
alogue accurately reflects the intended interaction
type. Based on this review, 93.1% of tasks were
accepted by at least two annotators for task faith-
fulness, and 91.6% for interaction-type alignment
45225
(all three agreed unanimously on 90.3% and 88.2%
of tasks, respectively, with no systematic author-
versus-external divide; Appendix A.1). To check
CHK-6e7b23dcb21d913819c2f234
ment
45225
(all three agreed unanimously on 90.3% and 88.2%
of tasks, respectively, with no systematic author-
versus-external divide; Appendix A.1). To check
the generated intermediate test cases, the authors
audited a random sample of 150 instances across
expansion and editing and found that 98.7% of tests
were well-aligned with their corresponding turn in-
structions, indicating that the pipeline produces reli-
able intermediate evaluations. Rejected tasks were
then manually rewritten before inclusion in the fi-
nal benchmark. In total, we spent over 90 human
hours on verification and correction, an estimated
180–270 hours less than fully manual construction.
Automated Feedback-Based Construction for
DebuggingWe construct multi-turn debugging
tasks using automated feedback derived from cor-
rectness and security test results, applied to a subset
of 262 tasks from SECCODEPLT selected for their
multiple-unit-test structure and dynamic test sup-
port. After each model response, we execute cor-
rectness and security tests and provide templated
natural language feedback indicating whether the
code fails correctness checks, contains security
vulnerabilities, or both. The interaction continues
until all issues are resolved or a maximum of five
turns is reached. Final performance is evaluated
on a held-out set of test cases disjoint from those
CHK-13d4db15f555e555f5bb63b5
ntinues
until all issues are resolved or a maximum of five
turns is reached. Final performance is evaluated
on a held-out set of test cases disjoint from those
used for feedback, ensuring that both feedback and
evaluation are grounded in human-authored tests.
MT-Sec Statistics.MT-Sec includes 2,638
multi-turn tasks across six programming languages
(PYTHON, JAVASCRIPT, GO, PHP, RUBY, RUST),
generated from 792 seed prompts spanning 27
CWEs: 2,376 human-verified tasks (792 each for
expansion, editing, and refactoring) plus 262 de-
bugging tasks. Each task includes both correctness
and security unit tests. Our 27 CWEs span the
same weakness classes emphasized by MITRE’s
2025 CWE Top-25 (injection, access control,
cryptographic failures, resource exhaustion), and
include two categories that are new entries on the
2025 list (CWE-284, CWE-770). Unlike many
secure-coding benchmarks restricted to Python,
MT-Sec spans six languages while retaining
enough samples per CWE to break down perfor-
mance by individual weakness (Appendix I) and
keep the set manually auditable. See Appendix A
for per-CWE and per-language distributions.
Evaluation Metrics.We use two primary met-
rics:(i) Correct & Secure (C&S):the proportion
of instances that pass both correctness and secu-
rity tests; and(ii) Correct & Insecure (C&I):the
proportion that pass correctness tests but fail one
or more security tests.
CHK-356074578aa1c4f165332bcb
hat pass both correctness and secu-
rity tests; and(ii) Correct & Insecure (C&I):the
proportion that pass correctness tests but fail one
or more security tests. In certain analyses, we also
report the aggregated correctness metric (C&S +
C&I). Unless otherwise specified, we report met-
rics on the final code produced after all turns are
completed. We additionally evaluate intermediate-
turn outputs where noted (see §4). See Ap-
pendix A.1 for further details on evaluation setup.
4 Evaluations & Insights
Experimental Setup.We evaluate 31 open-source
and proprietary LLMs, as well as three state-of-
the-art open-source agent frameworks (Aider,
OpenHands, and Codex) on MT-Sec. We use
MT-SECCODEPLT to denote the subset of MT-Sec
constructed from SECCODEPLT prompts. Unless
otherwise noted, all reported MT metrics refer to
final-turn evaluation. Full details on model check-
points, evaluation protocols, prompt templates, and
computational costs are in Appendix B.
Although newer models achieve better secure
coding results in single-turn benchmarks, this
progress diminishes significantly in multi-turn
scenarios.To contextualize our findings, we high-
light a gap between single-turn and multi-turn eval-
uation. Across model families, rapid gains on
single-turn SecCodePLT (Nie et al., 2026) shrink
substantially in multi-turn settings: Claude Opus
CHK-6c817d1afee231272ac5b69f
lti-turn eval-
uation. Across model families, rapid gains on
single-turn SecCodePLT (Nie et al., 2026) shrink
substantially in multi-turn settings: Claude Opus
4 improves over Claude 3.5 Sonnet by 13.2% on
SecCodePLT but only 4.7% on MT-Expansion, and
Qwen-38BT improves over Qwen-30.6BT by 31% on
SecCodePLT but only 10.7% on MT-Expansion.
Expansion and editing are consistently the
most challenging settings for secure code
generation.As shown in Table 2, even the
strongest models achieve only moderate C&S in
these regimes (roughly 36% and 42%), whereas
refactoring is more favorable (peaking at 47.9%
C&S), and debugging is substantially higher for
most large models (70–92% C&S with very low
C&I). GPT-5T achieves the best MT-average C&S
(52.7) and leads debugging (91.6 C&S, 3.1 C&I),
while Claude Opus 4T is tied for the top in editing
(41.7 C&S, tied with O3 Mini T) and is among
the top in refactoring (47.7 C&S, peaking at 47.9
for Claude Sonnet 4 T). Among open-weight
models, the recent Kimi-K2.7-Code and GLM-5.2
are strongest (48.6 and 47.7 MT-average C&S),
approaching the top proprietary systems while
still trailing GPT-5T (52.7). The interaction-type
ordering (expansion and editing hardest, refactor-
45226
Table 2: Multi-turn (MT) performance across interaction types. Higher correct & secure (C&S) and lower correct &
insecure (C&I) indicate better performance.
CHK-71a752a3b3b27378ba20acbb
26
Table 2: Multi-turn (MT) performance across interaction types. Higher correct & secure (C&S) and lower correct &
insecure (C&I) indicate better performance. Top three performers per column are bolded and the worst underlined.
MT-Average (C&S) is the mean C&S over all four interaction types; models are sorted by this MT-Average. Overall,
performance is lowest in expansion/editing, stable in refactoring, while debugging yields high C&S for strong
models. Thinking models are denoted by T.
MT-Expansion MT-Editing MT-Refactor MT-Debugging MT-Average
C&S↑C&I↓C&S↑C&I↓C&S↑C&I↓C&S↑C&I↓C&S↑
GPT-5T 34.911.9 40.0 14.1 44.3 10.591.6 3.1 52.7
Claude Opus 4T 30.8 14.741.713.547.711.1 84.0 3.451.0
GPT-5 MiniT 36.210.7 40.5 13.2 41.0 12.1 84.0 6.250.4
O4 MiniT 30.8 11.041.611.5 42.5 10.9 85.52.750.1
O3 MiniT 30.9 11.641.711.7 42.2 11.1 85.5 3.8 50.0
GPT-5T (Codex) 29.0 15.9 35.6 14.4 43.9 14.8 89.73.1 49.6
Claude Sonnet 4T 30.1 15.1 38.3 13.447.911.8 81.3 3.4 49.4
O3T 31.1 11.0 40.9 10.9 38.9 10.2 85.8 6.9 49.2
Kimi-K2.7-Code 31.712.7 38.8 12.445.614.0 78.4 3.2 48.6
O1T 28.8 11.6 38.8 12.7 42.2 11.0 84.0 4.2 48.5
GPT-5T (OpenHands) 27.2 17.5 35.1 16.1 40.3 14.090.93.4 48.4
Claude 3.7 SonnetT 30.2 13.9 39.0 13.2 44.7 11.6 77.5 6.2 47.8
GLM-5.2 30.7 13.2 35.9 12.7 42.9 13.7 81.4 3.4 47.7
GPT-5T (Aider) 25.7 14.8 38.8 13.8 43.0 10.4 82.2 4.1 47.4
CHK-b192123afd0ae5f98d781ebe
netT 30.2 13.9 39.0 13.2 44.7 11.6 77.5 6.2 47.8
GLM-5.2 30.7 13.2 35.9 12.7 42.9 13.7 81.4 3.4 47.7
GPT-5T (Aider) 25.7 14.8 38.8 13.8 43.0 10.4 82.2 4.1 47.4
Gemini 2.5 ProT 30.9 12.2 36.4 11.7 42.0 10.6 74.6 5.5 46.0
GPT-4.1 29.0 12.6 39.3 10.1 38.7 9.9 75.6 4.3 45.7
Claude 3.7 Sonnet 29.0 12.9 36.4 14.2 40.7 11.7 72.5 5.0 44.7
Gemma-4-31B-it 24.9 11.2 33.3 11.4 38.5 11.5 73.3 3.2 42.5
GPT-4o 26.7 10.5 29.4 12.5 35.6 9.9 77.8 5.0 42.4
Claude 3.5 Sonnet 26.1 10.6 28.4 10.2 32.2 9.0 69.1 4.6 38.9
Deepseek-V3 22.6 11.9 28.5 11.3 35.3 10.8 68.5 4.4 38.7
Qwen3-235B-A22BT 24.1 12.6 28.2 13.5 33.6 12.1 66.4 4.9 38.1
Gemini 2.5 FlashT 19.8 8.5 22.4 8.0 27.18.073.0 3.2 35.6
Qwen-38B
T 15.7 10.9 19.1 8.6 23.9 8.9 57.9 3.9 29.1
Qwen-38B 14.8 10.5 16.3 10.3 23.3 8.7 61.23.128.9
Qwen-2.5 Coder7B 14.2 10.1 19.6 9.0 19.2 10.3 54.8 4.6 27.0
Qwen-34B
T 14.3 8.6 15.5 9.4 19.3 8.5 56.5 4.1 26.4
Qwen-34B 13.4 9.5 15.6 9.8 19.4 9.5 52.7 4.3 25.3
Qwen-2.5 Coder3B 10.9 9.6 11.5 9.5 11.9 10.6 40.3 4.3 18.7
Qwen-31.7B
T 8.8 6.7 11.3 9.1 13.8 8.7 32.7 8.7 16.6
Qwen-31.7B 8.5 8.1 9.57.610.1 9.8 30.3 8.4 14.6
Qwen-30.6B
T 5.06.13.0 6.64.68.216.9 20.9 7.4
Qwen-30.6B 2.4 4.03.4 8.9 5.1 9.2 15.1 18.0 6.5
Qwen-2.5 Coder0.5B 4.55.24.26.03.0 7.613.9 8.0 6.4
ing easier, debugging highest) and the single- to
multi-turn drop hold across every open-weight
family we evaluate (Kimi, GLM, DeepSeek,
CHK-5c6d3a427eaed8f59dd5242a
6.03.0 7.613.9 8.0 6.4
ing easier, debugging highest) and the single- to
multi-turn drop hold across every open-weight
family we evaluate (Kimi, GLM, DeepSeek,
Gemma, and Qwen). For instance, expansion falls
45.5→31.7 for Kimi and 43.5→30.7 for GLM, so
the degradation is not specific to any one family.
Scaling within a family helps but does not close the
gap: Qwen3-235B-A22BT improves MT-average
over Qwen-38BT (38.1 vs. 29.1) while still degrad-
ing sharply across turns. Notably, C&I remains
low for top-performing models in debugging
(typically 2.7–6.9), but rises in expansion/editing,
indicating that the hardest MT settings degrade
both correctness-and-security simultaneously.
Intermediate-turn evaluation (Figure 10) reveals
that C&S declines monotonically across turns for
expansion, with the performance gap between
models shrinking at each successive turn. This
suggests that stronger models are not merely
better at individual turns but are disproportionately
affected by accumulating cross-turn dependencies.
Similar trends hold for editing and refactoring; for
debugging (up to five turns, with early exit when
all tests pass), C&S increases rapidly at Turn 2
and then saturates (Appendix K). To understand
whymodels fail, we categorize errors across
failing multi-turn samples using a manual-error
analysis taxonomy followed by LLM-as-a-judge
CHK-a9e03223df1cf2a0c096f6e4
ndix K). To understand
whymodels fail, we categorize errors across
failing multi-turn samples using a manual-error
analysis taxonomy followed by LLM-as-a-judge
classification (Zheng et al., 2023; Deshpande et al.,
2025; Kim et al., 2025). We identify three dom-
inant failure modes: (1) security neglect (60.3%),
where models drop security constraints (input
validation, sanitization, access control) as new turn
instructions shift attention; (2) scope narrowing
45227
(28.5%), where models implement the latest turn
too literally, losing broader task specifications;
and (3) context loss (9.0%), where setup code
or helper functions from earlier turns are silently
dropped (the remaining 2.2% are uncategorized
failures, e.g., syntax errors or refusals). Overall,
63% of failures are security-specific, confirming
that multi-turn settings disproportionately erode
security rather than general correctness. Due
to space constraints, we provide details on the
LLM judge setup, qualitative examples, and per-
interaction-type breakdowns in Appendix D. These
proportions hold stable across three judge models
and four prompt variants (twelve configurations
in all; Appendix D.4).
Agent scaffolds underperform their underly-
ing base modelsacross MT settings, with particu-
larly weak performance in expansion and elevated
insecurity rates. For example, GPT-5 T (Aider)
CHK-2cbdef84b33cbe5a8c788a90
their underly-
ing base modelsacross MT settings, with particu-
larly weak performance in expansion and elevated
insecurity rates. For example, GPT-5 T (Aider)
achieves 25.7 C&S in MT-expansion and 47.4 MT-
average C&S overall, while GPT-5T (OpenHands)
attains 27.2 C&S in MT-expansion and exhibits the
highest C&I among the reported systems in both
expansion (17.5) and editing (16.1). These drops
are accompanied by characteristic failure modes
(tool invocation errors, multi-file confusion, and
incorrect file generation) that compound across
turns. Since coding agents are typically designed
to solicit human confirmation when uncertain, we
confirm all actions programmatically to enable
scalable evaluation; this fully automated, mostly
single-file, specification-only regime (without
human-in-the-loop correction or realistic repository
context) may amplify scaffold-level errors that
human oversight would catch in practice. Detailed
agent configurations are in Appendix E.1, a taxon-
omy of failure modes in Appendix F, full results in
Appendix C.4 and C.5, and Appendix C.3 shows
that agent performance improves significantly with
oracle execution feedback.
Thinking models exhibit spurious refusals as
context accumulates.While “thinking” models
typically outperform their non-thinking counter-
parts, we observe a tendency to refuse multi-turn
CHK-af3f3e195947cb2cc1c0473b
ious refusals as
context accumulates.While “thinking” models
typically outperform their non-thinking counter-
parts, we observe a tendency to refuse multi-turn
requests that they handle successfully in single-turn
settings. For instance, in an MT-editing task,
Claude Sonnet 4T correctly implements safe arith-
metic evaluation in an early turn, but refuses when
the task evolves to executing general Python scripts
under the same safety constraints, responding: “I
can’t help create a function that executes arbitrary
user-supplied operations even with safety checks
in place...”. The model handles the equivalent
single-turn prompt without issue, suggesting that
accumulated context triggers overly cautious safety
filters. This behavior is most prevalent in CWE-95
tasks (Improper Neutralization of Directives in
Dynamically Evaluated Code): no refusals occur
in single-turn, but measurable rates appear in multi-
turn editing and expansion. Claude Sonnet 4T and
O3T are most affected (2.7% and 0.8% over-refusal
rates respectively), identified via regex-based
heuristics and manual verification. These rates are
conservative and may under-report true frequency.
Table 3: Correctness & security / insecurity when
models generate full code (MT) vs. code-diffs (MT +
CodeDiff) on a split of MT-Sec (editing). Deltas and p-
values (paired McNemar’s test:∗p <0.05 ,†p <0.01 ,
CHK-d352f0cd691304b62305eaac
models generate full code (MT) vs. code-diffs (MT +
CodeDiff) on a split of MT-Sec (editing). Deltas and p-
values (paired McNemar’s test:∗p <0.05 ,†p <0.01 ,
‡p <0.001) are relative to the MT column.
MT MT + CodeDiff
C&S↑C&I↓C&S↑C&I↓
O4 MiniT 48.1 14.5 37.7 ‡(−10.5) 19.2†(+4.7)
O3T 46.9 13.7 44.6(−2.2) 15.5(+1.7)
(Aider)+ O3 T 45.4 12.7 42.9(−2.5) 13.5(+0.8)
Qwen-2.5 Coder32B 42.9 14.2 22.6‡(−20.3) 14.8(+0.6)
GPT-4o 40.1 16.0 29.1‡(−11.1) 19.8∗(+3.8)
Claude 3.7 Sonnet 39.4 19.0 29.7 ‡(−9.7) 22.4(+3.5)
The difficulty of multi-turn tasks stems from
cross-turn dependencies, not longer context.A
natural question is whether the task difficulty in
the multi-turn setting is primarily due to increased
input length rather than challenges unique to multi-
turn reasoning. To isolate this, we introduceMT-
Random, which preserves the three-turn structure
but replaces the first two turns with prompts from
unrelated tasks (different CWEs), keeping only the
final turn as the target. This removes cross-turn de-
pendencies while maintaining or exceeding the in-
put length of standard multi-turn tasks (e.g.,∼566
tokens vs. 277.4 in EXPANSION). We conduct this
experiment on MT-SECCODEPLT. Results for
four models across three families (Fig. 3) show
that MT-Random performance closely matches or
slightly exceeds Single-Turn results. For example,
GPT-4o achieves 52.2% in Single-Turn, 52.5% in
CHK-eff9e257716f820a75278296
s (Fig. 3) show
that MT-Random performance closely matches or
slightly exceeds Single-Turn results. For example,
GPT-4o achieves 52.2% in Single-Turn, 52.5% in
MT-Random, but drops to 31.7% in MT-Expansion.
While some open-source models (e.g., Qwen3 8B)
show modest declines in MT-Random (6%), these
are smaller than drops in MT-Expansion (12%)
or MT-Editing (8%). This comparison yields two
key insights: (i) increased input length alone does
not account for the performance drop; and (ii) the
degradation in realistic multi-turn settings arises
45228
ST
MT-RandomMT-Expansion
MT-EditingMT-RefactorMT-Debugging
0
25
50
75
100
Performance
(%)
36.2 33.2 21.0 28.7 34.2
52.7
Qwen-34B
ST
MT-RandomMT-Expansion
MT-EditingMT-RefactorMT-Debugging
36.0 30.2 24.2 28.2 38.4
61.2
Qwen-38B
ST
MT-RandomMT-Expansion
MT-EditingMT-RefactorMT-Debugging
47.8 48.2 35.2 39.4 51.6
72.5
Claude 3.7 Sonnet
ST
MT-RandomMT-Expansion
MT-EditingMT-RefactorMT-Debugging
52.2 52.5
31.7 40.1 50.9
77.8
GPT-4o
Correct & Secure Correct & Insecure Incorrect
Figure 3: Performance comparison between Single-Turn (ST), standard Multi-Turn (MT) settings, and a control
condition, MT-Random on MT-SECCODEPLT. In MT-Random, context length is matched to MT by including
unrelated prior turns, isolating the effect of longer input without introducing cross-turn dependencies. Results across
CHK-0b83130aea4de3033f1ca181
xt length is matched to MT by including
unrelated prior turns, isolating the effect of longer input without introducing cross-turn dependencies. Results across
four models show that performance in MT-Random is comparable to, or slightly better than, ST, indicating that
increased input length alone does not cause degradation.
from the added complexity of reasoning over
related turns–requiring models to track evolving
goals, modify prior code, and maintain coherence
across interactions. While MT-Random controls
for total context length, it does not address the
possible impact of target task length. We analyze
this separately in Appendix C.1 and find that
variation in task length does not explain the sharp
performance decline in multi-turn scenarios.
Effect of security-policy on multi-turn.Prior
work (Nie et al., 2026; Vero et al., 2025) shows that
appending a short security policy (e.g., “Ensure
query execution avoids eval() or exec() to pre-
vent untrusted code execution”) improves single-
turn performance. We examine whether this trans-
fers to multi-turn by inserting the policy at differ-
ent points (system prompt, first turn, last turn, or
every turn) and evaluate on expansion using MT-
SECCODEPLT (Table 4). Even with the best place-
ment, multi-turn performance remains below the
single-turn baseline without any policy. Only suf-
CHK-db9b10717c6bd367f31c89c4
ion using MT-
SECCODEPLT (Table 4). Even with the best place-
ment, multi-turn performance remains below the
single-turn baseline without any policy. Only suf-
ficiently capable models benefit: smaller models
show modest gains (2–4%), while O3 T, GPT-4o,
and Claude 3.7 Sonnet achieve substantial gains (3–
14% depending on placement, with best-policy im-
provements of 8–14%). Optimal placement varies
by model family: OpenAI models perform best
with last-turn placement (e.g., O3 T: 49.4% C&S
vs. 47.1% with every-turn), as repeating the policy
can cause models to revise previously correct secu-
rity logic, while Claude 3.7 Sonnet benefits from
every-turn placement (see Appendix D). Notably,
even in single-turn, policy-based prompting sig-
nificantly underperforms test-case-based feedback
(i.e., debugging), suggesting that natural language
reminders are not the optimal form of security guid-
ance.
Code-diff generation reduces secure coding
rates and increases the proportion of insecure
outputs.To evaluate this increasingly common
mode of interaction, we design an experiment
where LLMs generate full code in Turn-1, followed
by unified-diff-style code patches in Turns 2 and
3 on MT-SECCODEPLT. Each generated diff is
programmatically applied to the existing code to
reconstruct the complete program for evaluation,
with the LLM provided the current code state and
CHK-b00cee8537fdd80bf3bc97d1
ated diff is
programmatically applied to the existing code to
reconstruct the complete program for evaluation,
with the LLM provided the current code state and
relevant context at each turn.
Results are shown in Table 3 for editing
interaction type; most rows are pure LLMs, with
the third using Aider (additional agent analyses
in Appendix C.6). Across all models, we observe
a consistent decline in correctness & security
performance in the code-diff setting compared
to full-code generation, indicating that current
models struggle with targeted edits that must
preserve the security of surrounding code. More
concerningly, C&I increases across the board,
highlighting the risks of relying on code-diff
generation in security-sensitive contexts.
Additional Empirical Investigations.We
document recurring qualitative failure modes
observed across models, and how strategies to
address them help (Appendix D), the effect of
increasing the number of turns (Appendix C.2), the
effect of providing execution feedback to coding
agents (Appendix C.3), and ablation studies on the
Aider agent (Appendices C.4, C.5, C.6).
5 Discussion & Conclusions
We introduced MT-Sec, a benchmark for evaluat-
ing LLMs on multi-turn secure coding tasks across
45229
Table 4: Single-turn (ST) and multi-turn (MT) performance, reported as mean (%) showing only CS metric. Policy
CHK-c122f5258bee1eedb8f0717e
on multi-turn secure coding tasks across
45229
Table 4: Single-turn (ST) and multi-turn (MT) performance, reported as mean (%) showing only CS metric. Policy
blocks show the absolute value, ∆ from their baseline (ST or MT), and p-value (paired McNemar’s test:∗p <0.05 ,
†p <0.01, ‡p <0.001). For each model, the best-performing MT policy (highest CS) is highlighted in green.
ST ST + Sec. Policy MT MT + SysPrompt MT + First-Turn MT + Last-Turn MT + Every-Turn
CS↑CS↑CS↑CS↑CS↑CS↑CS↑
(Aider)+ O3 T 67.2 78.3 (+11.1) 44.3 51.5 †(+7.2) 51.1†(+6.8) 54.4‡(+10.1) 51.0†(+6.7)
O3T 57.5 66.8 ‡(+9.3) 41.4 46.1 ∗(+4.7) 44.6(+3.2) 49.4‡(+8.0) 47.1∗(+5.7)
O4 MiniT 56.8 65.5 ‡(+8.8) 38.7 43.1 (+4.5) 43.6∗(+5.0) 45.1†(+6.5) 41.9(+3.2)
GPT-4o 52.2 60.0 ‡(+7.8) 31.7 42.4 ‡(+10.7) 40.4‡(+8.7) 45.4‡(+13.7) 40.9‡(+9.2)
Claude 3.7 Sonnet 47.8 53.2 †(+5.5) 35.2 44.1 ‡(+9.0) 45.4‡(+10.2) 43.6‡(+8.5) 46.6‡(+11.5)
Qwen-38B 36.0 43.5 †(+7.5) 24.2 29.1 ∗(+5.0) 36.4‡(+12.2) 35.3‡(+11.1) 33.9‡(+9.7)
Qwen-34B 36.2 41.2 ∗(+5.0) 21.0 23.9 (+2.9) 24.7(+3.7) 30.4‡(+9.4) 23.9(+2.9)
Qwen-31.7B 19.8 27.5 ‡(+7.8) 14.3 14.0 (−0.3) 12.8(−1.5) 15.0(+0.8) 17.2(+2.9)
Qwen-30.6B 8.0 9.5 (+1.5) 2.8 5.8∗(+3.0) 5.2(+2.5) 4.8(+2.0) 3.0(+0.3)
four realistic interaction types:expansion,editing,
refactoring, anddebugging. Our evaluation of 31
models and three agent frameworks reveals that
CHK-3d8c744b391d9b54b26a8042
0) 3.0(+0.3)
four realistic interaction types:expansion,editing,
refactoring, anddebugging. Our evaluation of 31
models and three agent frameworks reveals that
multi-turn interactions remain a significant chal-
lenge for current LLMs. We find thatexpansion
andeditingare the most difficult interaction types,
often resulting in correct but insecure code due to
difficulties integrating changes while preserving
security constraints. Surprisingly, agent-based sys-
tems often underperform their base LLMs in multi-
turn settings, struggling with tool errors and coor-
dination issues when feedback or context evolves.
Beyond quantitative results, MT-Sec provides qual-
itative insights into key model failure modes, such
as: (1) neglecting security constraints as new turn
instructions shift attention (security neglect); (2)
implementing the latest turn too literally, losing
broader task specifications (scope narrowing); and
(3) silently dropping setup code or helper functions
from earlier turns (context loss).
6 Limitations
In this section, we discuss key limitations of
our work and potential for future improvements.
Our human-verified tasks focus on three-turn dia-
logues; while preliminary experiments extend to
10 turns (Appendix C.2), scaling expert verification
to longer sequences while maintaining quality con-
trol and reproducibility remains an open challenge.
CHK-f0fbfcb3f9ada3d35687d20c
to
10 turns (Appendix C.2), scaling expert verification
to longer sequences while maintaining quality con-
trol and reproducibility remains an open challenge.
Our debugging interaction uses templated unit-test
feedback, which we show is more reliable than
LLM-simulated user feedback (Appendix J); future
work could broaden this to additional feedback sig-
nals, such as developer-authored natural-language
critiques. We also leave training LLMs on curated
multi-turn secure coding data to future work; MT-
Sec can support this direction by guiding both data
generation and evaluation at scale.
7 Ethical considerations
Insecure code generated by LLMs can lead to crit-
ical vulnerabilities, exposing systems to outages,
data breaches, and exploitation by malicious actors.
Our benchmark provides a realistic, multi-turn eval-
uation framework that reflects how code is written
in practice. We believe that systematically measur-
ing LLMs’ secure coding capabilities is a necessary
step toward building safer AI-assisted development
tools. However, releasing such benchmarks may
also enable adversaries to identify blind spots in
current models, which could be misused; we en-
courage responsible use and continued research
into improving model security.
Acknowledgments
This research was supported in part by Coefficient
Giving, an NSF CAREER Award CNS-2442719,
CHK-f53f6e16ce82cf3ace52e18e
d continued research
into improving model security.
Acknowledgments
This research was supported in part by Coefficient
Giving, an NSF CAREER Award CNS-2442719,
DARPA TIAMAT and the NSF TRAILS Institute
(2229885), commercial support from Capital One
Bank, the Amazon Research Award program, and
generous gifts from Google DeepMind and Ope-
nAI.
References
Manish Bhatt, Sahana Chennabasappa, Cyrus Niko-
laidis, Shengye Wan, Ivan Evtimov, Dominik Gabi,
Daniel Song, Faizan Ahmad, Cornelius Aschermann,
Lorenzo Fontana, Sasha Frolov, Ravi Prakash Giri,
Dhaval Kapil, Yiannis Kozyrakis, David LeBlanc,
James Milazzo, Aleksandar Straumann, Gabriel Syn-
naeve, Varun V ontimitta, and 2 others. 2023. Purple
llama cyberseceval: A secure coding benchmark for
language models.Preprint, arXiv:2312.04724.
45230
Wachiraphan Charoenwet, Patanamon Thongtanunam,
Van-Thuan Pham, and Christoph Treude. 2024. An
empirical study of static analysis tools for secure code
review. InProceedings of the 33rd ACM SIGSOFT
International Symposium on Software Testing and
Analysis, pages 691–703.
Junkai Chen, Huihui Huang, Yunbo Lyu, Junwen An,
Jieke Shi, Chengran Yang, Ting Zhang, Haoye Tian,
Yikun Li, Zhenhao Li, Xin Zhou, Xing Hu, and
David Lo. 2026. SecureVibeBench: Benchmarking
secure vibe coding of AI agents via reconstructing
vulnerability-introducing scenarios. InProceedings
CHK-9127da35e8d150177a673a60
ing Hu, and
David Lo. 2026. SecureVibeBench: Benchmarking
secure vibe coding of AI agents via reconstructing
vulnerability-introducing scenarios. InProceedings
of the 64th Annual Meeting of the Association for
Computational Linguistics (Volume 1: Long Papers),
pages 24144–24168, San Diego, California, United
States. Association for Computational Linguistics.
Mariana Coutinho, Lorena Marques, Anderson San-
tos, Marcio Dahia, César França, and Ronnie
de Souza Santos. 2024. The role of generative ai
in software development productivity: A pilot case
study.ArXiv, abs/2406.00560.
Cursor. 2025. Cursor. https://www.cursor.com/ .
Accessed: 2025-05-09.
Kaustubh Deshpande, Ved Sirdeshmukh, Johannes Bap-
tist Mols, Lifeng Jin, Ed-Yeremai Hernandez-
Cardona, Dean Lee, Jeremy Kritz, Willow E Primack,
Summer Yue, and Chen Xing. 2025. Multichallenge:
A realistic multi-turn conversation evaluation bench-
mark challenging to frontier llms. InFindings of
the Association for Computational Linguistics: ACL
2025, pages 18632–18702.
Paul Gauthier. 2023. Aider: Ai-assisted coding in your
terminal with gpt. https://aider.chat/ . Ac-
cessed: 2025-05-15.
GitHub. 2025. Github copilot. https://github.com
/features/copilot. Accessed: 2025-05-09.
Hojae Han, Seung-won Hwang, Rajhans Samdani,
and Yuxiong He. 2025. Convcodeworld: Bench-
marking conversational code generation in repro-
CHK-8eee6be02b6bc4a4e4c389b1
Accessed: 2025-05-09.
Hojae Han, Seung-won Hwang, Rajhans Samdani,
and Yuxiong He. 2025. Convcodeworld: Bench-
marking conversational code generation in repro-
ducible feedback environments.arXiv preprint
arXiv:2502.19852.
Yun He, Di Jin, Chaoqi Wang, Chloe Bi, Karishma
Mandyam, Hejia Zhang, Chen Zhu, Ning Li, Tengyu
Xu, Hongjiang Lv, Shruti Bhosale, Chenguang Zhu,
Karthik Abinav Sankararaman, Eryk Helenowski,
Melanie Kambadur, Aditya Tayade, Hao Ma, Han
Fang, and Sinong Wang. 2024. Multi-if: Benchmark-
ing llms on multi-turn and multilingual instructions
following.Preprint, arXiv:2410.15553.
Eirini Kalliamvakou. 2022. Research: quantifying
GitHub Copilot’s impact on developer productivity
and happiness. https://github.blog/news-ins
ights/research/research-quantifying-git
hub-copilots-impact-on-developer-product
ivity-and-happiness/ . GitHub Blog. Accessed:
2026-08-30.
Myeongsoo Kim, Shweta Garg, Baishakhi Ray, Varun
Kumar, and Anoop Deoras. 2025. Codeassistbench
(cab): Dataset & benchmarking for multi-turn chat-
based code assistance.Advances in Neural Informa-
tion Processing Systems, 38.
Wai-Chung Kwan, Xingshan Zeng, Yuxin Jiang, Yufei
Wang, Liangyou Li, Lifeng Shang, Xin Jiang, Qun
Liu, and Kam-Fai Wong. 2024. MT-eval: A multi-
turn capabilities evaluation benchmark for large lan-
guage models. InProceedings of the 2024 Confer-
CHK-7c0cc1df47e6b75bd68d993a
Jiang, Qun
Liu, and Kam-Fai Wong. 2024. MT-eval: A multi-
turn capabilities evaluation benchmark for large lan-
guage models. InProceedings of the 2024 Confer-
ence on Empirical Methods in Natural Language Pro-
cessing, pages 20153–20177, Miami, Florida, USA.
Association for Computational Linguistics.
Bennett P. Lientz and E. Burton Swanson. 1980.Soft-
ware Maintenance Management. Addison-Wesley
Longman Publishing Co., Inc., USA.
Zefang Liu, Jialei Shi, and John F Buford. 2024. Cy-
berbench: A multi-task benchmark for evaluating
large language models in cybersecurity. InAAAI
2024 Workshop on Artificial Intelligence for Cyber
Security.
MITRE Corporation. 2025. Common weakness enumer-
ation (cwe) list, version 4.17. https://cwe.mitre.
org/data/index.html. Accessed: 2025-05-12.
Saikat Mondal, Suborno Deb Bappon, and Chanchal K.
Roy. 2024. Enhancing user interaction in chatgpt:
Characterizing and consolidating multiple prompts
for issue resolution. InProceedings of the 21st Inter-
national Conference on Mining Software Reposito-
ries, MSR ’24, page 222–226, New York, NY , USA.
Association for Computing Machinery.
Yuzhou Nie, Zhun Wang, Yu Yang, Ruizhe Jiang,
Yuheng Tang, Xander Davies, Yarin Gal, Bo Li,
Wenbo Guo, and Dawn Song. 2026. SECODEPLT:
A unified benchmark for evaluating the security risks
and capabilities of code genAI. InThe Thirty-ninth
CHK-7b8e6a9601c8fee4530d4204
Gal, Bo Li,
Wenbo Guo, and Dawn Song. 2026. SECODEPLT:
A unified benchmark for evaluating the security risks
and capabilities of code genAI. InThe Thirty-ninth
Annual Conference on Neural Information Process-
ing Systems Datasets and Benchmarks Track.
Erik Nijkamp, Bo Pang, Hiroaki Hayashi, Lifu Tu, Huan
Wang, Yingbo Zhou, Silvio Savarese, and Caiming
Xiong. 2022. Codegen: An open large language
model for code with multi-turn program synthesis.
arXiv preprint arXiv:2203.13474.
OpenAI. 2025. Openai codex cli: Lightweight coding
agent that runs in your terminal. https://github
.com/openai/codex. [Accessed 15-05-2025].
Hammond Pearce, Baleegh Ahmad, Benjamin Tan,
Brendan Dolan-Gavitt, and Ramesh Karri. 2025.
Asleep at the keyboard? assessing the security of
github copilot’s code contributions.Communications
of the ACM, 68(2):96–105.
Jinjun Peng, Leyi Cui, Kele Huang, Junfeng Yang, and
Baishakhi Ray. 2025. Cweval: Outcome-driven eval-
uation on functionality and security of llm code gen-
eration.Preprint, arXiv:2501.08200.
45231
Sanka Rasnayaka, Guanlin Wang, Ridwan Shariffdeen,
and Ganesh Neelakanta Iyer. 2024. An empirical
study on usage and perceptions of llms in a soft-
ware engineering project.2024 IEEE/ACM Inter-
national Workshop on Large Language Models for
Code (LLM4Code), pages 111–118.
Chihao Shen, Connor Dilgren, Purva Chiniya, Luke
CHK-17dab5aedeed063f01c56014
ng project.2024 IEEE/ACM Inter-
national Workshop on Large Language Models for
Code (LLM4Code), pages 111–118.
Chihao Shen, Connor Dilgren, Purva Chiniya, Luke
Griffith, Yu Ding, and Yizheng Chen. 2025. Secre-
pobench: Benchmarking code agents for secure code
completion in real-world repositories.arXiv preprint
arXiv:2504.21205.
E Burton Swanson. 1976. The dimensions of main-
tenance. InProceedings of the 2nd international
conference on Software engineering, pages 492–497.
Maxim Tabachnyk and Stoyan Nikolov. 2022. ML-
enhanced code completion improves developer pro-
ductivity. https://research.google/blog/m
l-enhanced-code-completion-improves-dev
eloper-productivity/ . Google Research Blog.
Accessed: 2026-08-30.
Benyamin Tabarsi, Heidi Reichert, Ally Limke, Sandeep
Kuttal, and Tiffany Barnes. 2025. Llms’ reshaping of
people, processes, products, and society in software
development: A comprehensive exploration with
early adopters.arXiv preprint arXiv:2503.05012.
Runchu Tian, Yining Ye, Yujia Qin, Xin Cong, Yankai
Lin, Yinxu Pan, Yesai Wu, Hui Haotian, Liu We-
ichuan, Zhiyuan Liu, and Maosong Sun. 2024. De-
bugBench: Evaluating debugging capability of large
language models. InFindings of the Association for
Computational Linguistics: ACL 2024, pages 4173–
4198, Bangkok, Thailand. Association for Computa-
tional Linguistics.
Mark Vero, Niels Mündler, Victor Chibotaru, Veselin
CHK-5e79b21d5bada4e363629ad5
al Linguistics: ACL 2024, pages 4173–
4198, Bangkok, Thailand. Association for Computa-
tional Linguistics.
Mark Vero, Niels Mündler, Victor Chibotaru, Veselin
Raychev, Maximilian Baader, Nikola Jovanovi ´c,
Jingxuan He, and Martin Vechev. 2025. Baxbench:
Can LLMs generate correct and secure backends? In
Forty-second International Conference on Machine
Learning.
Sizhe Wang, Zhengren Wang, Dongsheng Ma, Yongan
Yu, Rui Ling, Zhiyu li, Feiyu Xiong, and Wentao
Zhang. 2026. CodeFlowBench: A multi-turn, iter-
ative benchmark for complex code generation. In
Proceedings of the 64th Annual Meeting of the As-
sociation for Computational Linguistics (Volume 1:
Long Papers), pages 4369–4402, San Diego, Cali-
fornia, United States. Association for Computational
Linguistics.
Xingyao Wang, Boxuan Li, Yufan Song, Frank F. Xu,
Xiangru Tang, Mingchen Zhuge, Jiayi Pan, Yueqi
Song, Bowen Li, Jaskirat Singh, Hoang H. Tran,
Fuqiang Li, Ren Ma, Mingzhang Zheng, Bill Qian,
Daniel Shao, Niklas Muennighoff, Yizhe Zhang,
Binyuan Hui, and 5 others. 2025. Openhands: An
open platform for AI software developers as gener-
alist agents. InThe Thirteenth International Confer-
ence on Learning Representations.
Xingyao Wang, Zihan Wang, Jiateng Liu, Yangyi
Chen, Lifan Yuan, Hao Peng, and Heng Ji. 2023.
Mint: Evaluating llms in multi-turn interaction
with tools and language feedback.arXiv preprint
CHK-05336e8baa922a587c2c1a5e
teng Liu, Yangyi
Chen, Lifan Yuan, Hao Peng, and Heng Ji. 2023.
Mint: Evaluating llms in multi-turn interaction
with tools and language feedback.arXiv preprint
arXiv:2309.10691.
Weibin Yang, Liangru Xie, Jieyun Cai, Yuxiang Yan,
Hong-Ning Dai, and Hao Wang. 2026. Talk2code:
A multi-turn interaction benchmark with dual-track
evaluation for code generation. InProceedings of
the AAAI Conference on Artificial Intelligence, vol-
ume 40, pages 34331–34339.
Binquan Zhang, Li Zhang, Haoyuan Zhang, Fang Liu,
Song Wang, Bo Shen, An Fu, and Lin Shi. 2025.
Decoding human-llm collaboration in coding: An
empirical study of multi-turn conversations in the
wild.arXiv preprint arXiv:2512.10493.
Kunhao Zheng, Juliette Decugis, Jonas Gehring, Taco
Cohen, Benjamin Negrevergne, and Gabriel Syn-
naeve. 2024. What makes large language models rea-
son in (multi-turn) code generation?arXiv preprint
arXiv:2410.08105.
Lianmin Zheng, Wei-Lin Chiang, Ying Sheng, Siyuan
Zhuang, Zhanghao Wu, Yonghao Zhuang, Zi Lin,
Zhuohan Li, Dacheng Li, Eric Xing, Hao Zhang,
Joseph E. Gonzalez, and Ion Stoica. 2023. Judging
LLM-as-a-judge with MT-bench and chatbot arena.
InThirty-seventh Conference on Neural Information
Processing Systems Datasets and Benchmarks Track.
Suzhen Zhong, Ying Zou, and Bram Adams. 2025.
Developer-llm conversations: An empirical study
of interactions and generated code quality.arXiv
CHK-85f18eb51122c706a8f7594c
enchmarks Track.
Suzhen Zhong, Ying Zou, and Bram Adams. 2025.
Developer-llm conversations: An empirical study
of interactions and generated code quality.arXiv
preprint arXiv:2509.10402.
45232
Appendix
A Additional Benchmark Details
A.1 Additional Construction & Evaluation
Details
Table 5: All open-source models are available via Hug-
gingFace, and proprietary models are available via re-
spective providers. Some thinking and non-thinking
models may have the same model-checkpoint, as there
are often separate hyper-parameters to set thinking bud-
get to zero.
Model Name Checkpoint
GPT-5T gpt-5-2025-08-07
GPT-5-MiniT gpt-5-mini-2025-08-07
GPT-4o gpt-4o-2024-11-20
GPT-4.1 gpt-4.1-2025-04-14
O1-MiniT o1-mini-2024-09-12
O3-MiniT o3-mini-2025-01-31
O1T o1-2024-12-17
O4-MiniT o4-mini-2025-04-16
O3T o3-2025-04-16
Claude 3.7 Sonnet claude-3-7-sonnet-20250219
Claude 3.5 Sonnet claude-3-5-sonnet-20240620
Claude 3.7 SonnetT claude-3-7-sonnet-20250219
Claude Sonnet 4T claude-sonnet-4-20250514
Claude Opus 4T claude-opus-4-20250514
Gemini-2.5-FlashT gemini-2.5-flash-preview-04-17
Gemini-2.5-Flash gemini-2.5-flash-preview-04-17
Gemini-2.5-ProT gemini-2.5-pro-preview-03-25
Gemini-2.5-Pro gemini-2.5-pro-preview-03-25
Qwen2.5 Coder 32B Qwen/Qwen2.5-Coder-32B-Instruct
Qwen2.5 Coder 14B Qwen/Qwen2.5-Coder-14B-Instruct
Qwen2.5 Coder 7B Qwen/Qwen2.5-Coder-7B-Instruct
CHK-a43146fd15bb007e64c87dc5
eview-03-25
Qwen2.5 Coder 32B Qwen/Qwen2.5-Coder-32B-Instruct
Qwen2.5 Coder 14B Qwen/Qwen2.5-Coder-14B-Instruct
Qwen2.5 Coder 7B Qwen/Qwen2.5-Coder-7B-Instruct
Qwen2.5 Coder 3B Qwen/Qwen2.5-Coder-3B-Instruct
Qwen2.5 Coder 1.5B Qwen/Qwen2.5-Coder-1.5B-Instruct
Qwen2.5 Coder 0.5B Qwen/Qwen2.5-Coder-0.5B-Instruct
Qwen3 32B Qwen/Qwen3-32B
Qwen3 32BT Qwen/Qwen3-32B
Qwen3 14B Qwen/Qwen3-14B
Qwen3 14BT Qwen/Qwen3-14B
Qwen3 8B Qwen/Qwen3-8B
Qwen3 8BT Qwen/Qwen3-8B
Qwen3 4B Qwen/Qwen3-4B
Qwen3 4BT Qwen/Qwen3-4B
Qwen3 1.7B Qwen/Qwen3-1.7B
Qwen3 1.7BT Qwen/Qwen3-1.7B
Qwen3 0.6B Qwen/Qwen3-0.6B
Qwen3 0.6BT Qwen/Qwen3-0.6B
Kimi-K2.7-Code moonshotai/Kimi-K2.7-Code
GLM-5.2 zai-org/GLM-5.2
Deepseek-V3 deepseek-ai/DeepSeek-V3
Gemma-4-31B-it google/gemma-4-31B-it
Qwen3-235B-A22BT Qwen/Qwen3-235B-A22B
Guardrails for different interaction types.
Consistency guardrails are lightweight, rule-based
checks that verify whether the generated multi-
turn instructions remain semantically aligned with
the original single-turn prompt metadata (function
name, arguments, return types, exception-handling
requirements). When a violation is detected, the
guardrail triggers automatic regeneration with tar-
geted feedback (e.g.,“The request is missing:
algorithm parameter”). Each interaction type
has four guardrail rules; debugging tasks do not
require guardrails because their turns are grounded
CHK-f0c41fa4c257814d334779ba
t is missing:
algorithm parameter”). Each interaction type
has four guardrail rules; debugging tasks do not
require guardrails because their turns are grounded
directly in test-case execution feedback.
Expansionguardrails enforce that: (1) the
target function name from the seed prompt does
notappear in the first turn, ensuring the interaction
begins with partial or auxiliary functionality; (2)
the target function namedoesappear in the final
turn, signaling the full implementation is being
requested; (3) all named arguments and return
types from the seed prompt are covered across
the turn sequence; and (4) any exception-handling
requirements encoded in the seed metadata are
mentioned in at least one turn.Editingguardrails
enforce that: (1) the same function name appears
in at least two consecutive turns, reflecting iterative
modification; (2) later turns contain modification-
related keywords (e.g., “modify,” “change,”
“update,” “improve”), indicating requirement
pivots rather than new functionality; (3) all named
arguments and return types are covered; and (4)
exception-handling requirements are preserved.
Refactoringguardrails enforce that: (1) the first
turn includes the target function name and return
type, preserving the original specification; (2) later
turns contain restructuring-related keywords (e.g.,
“refactor,” “reorganize,” “modularize,” “clean
CHK-c9baba981110f2a3b4ef311b
eturn
type, preserving the original specification; (2) later
turns contain restructuring-related keywords (e.g.,
“refactor,” “reorganize,” “modularize,” “clean
up”); (3) all arguments are covered; and (4)
exception-handling requirements are maintained.
While the data-generator LLMs used in our
pipeline generally produce high-quality multi-turn
sequences, these consistency guardrails act as a
fail-safe mechanism to catch systematic omissions
that are straightforward to detect using the avail-
able metadata. When a sequence fails a check
(for instance, if a required function name is miss-
ing), we automatically provide targeted feedback
to the LLM (e.g., prompting: “The request
is missing: {missing specifications},
please include it” ), and regenerate the cor-
responding turn. Multi-turn sequences that pass all
guardrails are then submitted for final human veri-
fication before being included in the benchmark.
Overall, approximately 18% of initially gener-
ated sequences trigger at least one guardrail viola-
tion, with editing exhibiting the highest rate (12%),
45233
followed by expansion (4%) and refactoring (2%).
The higher rate for editing reflects the difficulty of
generating requirement pivots that still reference
the correct function signature and arguments. Tasks
are regenerated up to three times; if a sequence still
fails after three attempts, we retain the most re-
CHK-5831182b130c8d1c079f64e7
e
the correct function signature and arguments. Tasks
are regenerated up to three times; if a sequence still
fails after three attempts, we retain the most re-
cently generated multi-turn requests, as the human
verification at the next step applies any appropriate
fixes required.
Human Annotation Protocol.Three annota-
tors participated in the verification process: two
authors of this paper and one external volunteer,
all with graduate-level training in software engi-
neering and security. Annotators were not com-
pensated for this effort, as it was conducted as part
of the research collaboration. Each annotator re-
ceived a separate Google Spreadsheet containing
one row per task, with columns for: (a) the origi-
nal single-turn prompt, (b) the generated three-turn
multi-turn sequence, (c) a binary (0/1) rating for
task faithfulness(whether the multi-turn instruc-
tions preserve all information needed to pass the
original correctness and security tests), and (d) a
binary (0/1) rating forinteraction-type alignment
(whether the dialogue accurately reflects the in-
tended interaction type, e.g., editing vs. expansion).
Annotators worked independently without discus-
sion during the annotation phase. We computed
agreement via majority voting: a task was accepted
if at least two of three annotators marked it as 1
on both dimensions. Tasks receiving a majority
CHK-453ec7d9818bf4121ce4504b
e computed
agreement via majority voting: a task was accepted
if at least two of three annotators marked it as 1
on both dimensions. Tasks receiving a majority
vote of 0 on either dimension were flagged for
revision and manually rewritten by one of the au-
thors to meet the required standards. The full an-
notation effort spanned approximately 90 human
hours across all annotators. All annotators were
informed of the purpose of the annotation task and
consented to the inclusion of their annotation out-
puts in the released benchmark. Beyond major-
ity acceptance, all three annotators agreed unan-
imously on 90.3% (task faithfulness) and 88.2%
(interaction-type alignment) of tasks, with pairwise
agreement of 94.5–97.4% and 89.2–96.4% respec-
tively. Because both dimensions require security
and software-engineering expertise, we used expert
annotators rather than crowdsourcing; the resid-
ual variation is annotator-specific rather than an
author-versus-external divide (the external annota-
tor’s highest agreement is with an author).
Licensing and Intended Use.The seed prompts
in MT-Sec are drawn from SECCODEPLT (Nie
et al., 2026) (MIT License) and BAXBENCH(Vero
et al., 2025) (MIT License). Our use is consis-
tent with the intended research purposes of both
datasets. We will release MT-Sec under the same
MIT License for research use.
Further Evaluation Details.All prompts in
CHK-0a616db3cbefd6127da1313c
the intended research purposes of both
datasets. We will release MT-Sec under the same
MIT License for research use.
Further Evaluation Details.All prompts in
MT-Sec are designed to elicit single (and occasion-
ally multi-file) code implementations wrapped in
appropriate language backticks. Following extrac-
tion guidelines from the base seed datasets, we au-
tomatically extract code blocks from model outputs
and run dynamic tests in a sandbox. For expansion
interactions, where functions may be built incre-
mentally, we concatenate outputs from all turns
before evaluation.
A.2 Overlap and Contamination Analysis
with Seed Benchmarks
Because MT-Sec reuses seed prompts and test
suites from SECCODEPLT (Nie et al., 2026) and
BAXBENCH(Vero et al., 2025), we quantify how
much of the source structure survives the multi-
turn transformation using verbatim n-gram over-
lap, measured in both directions between each seed
prompt and its generated dialogue.Retainedover-
lap enumerates the seed prompt’s n-grams and re-
ports the fraction that reappear verbatim in the di-
alogue, either anywhere or restricted to the final
scored turn, measuring how much of the original
prompt structure persists.New contentenumer-
ates the dialogue’s n-grams and reports the fraction
absent from the seed prompt, measuring how much
of what the model reads is material the seed never
contained.
CHK-0f7a533f0a724699a81568f4
es the dialogue’s n-grams and reports the fraction
absent from the seed prompt, measuring how much
of what the model reads is material the seed never
contained. Table 1 reports both at n= 4/8/10
for expansion, editing, and refactoring; we ex-
clude debugging, whose turns are generated dy-
namically from test-execution feedback rather than
transformed from seed text.
For expansion and editing, only about 20–25%
of the seed’s 8-grams reappear anywhere and 13–
21% in the final turn, while roughly 80% of the di-
alogue’s 8-grams never occur in the seed, since the
dialogue is substantially longer and introduces new
subtasks at each turn. What survives sits almost en-
tirely in the parts that must stay fixed for the reused
tests to remain valid: the target function signature
and its typed-argument block. An editing task that
pivots midway, for instance, still ends on the seed’s
signature encrypt_password(algorithm_name:
str, pwd: str), so the original test suite applies.
refactoring is the mirror image: Turn 1 restates
the task by design, giving high overall retention,
but the final instruction shares 0% of the seed’s 8-
45234
grams, since Turns 2 and 3 only ask to restructure
the code or add PEP-8-style documentation.
The two seed datasets follow the same pattern,
with BAXBENCHretention higher ( ∼28–30% vs.
∼17–18% at n= 8 ) because its seeds embed for-
CHK-b183dfc93dfbb81badd69c17
-style documentation.
The two seed datasets follow the same pattern,
with BAXBENCHretention higher ( ∼28–30% vs.
∼17–18% at n= 8 ) because its seeds embed for-
mal endpoint and API specifications that must be
carried verbatim, whereas SECCODEPLT seeds
are natural-language descriptions. Each dialogue
converges by design to an output evaluable by the
original unit tests, so we retain those suites and ver-
ify during human annotation (Appendix A.1) that
they remain valid for every sample. This generate-
then-verify construction from validated single-turn
seeds follows recent multi-turn benchmarks (He
et al., 2024; Kwan et al., 2024) and balances scala-
bility with quality.
A.3 Validating the Dynamic Security Tests
To estimate how often the dynamic suites pass in-
secure code (false negatives) and whether they gen-
eralize beyond the reference implementations they
ship with (coverage), we run two complementary
analyses on MT-SECCODEPLT.
Static-analysis cross-check (false negatives).
We run Semgrep on every MT-SECCODEPLT out-
put the suites label C&S. It flags 7.4%, all in
injection-related CWEs (code and command in-
jection) and none elsewhere. Manual inspection
(attempting real exploits and examining the guard
structure) shows that the large majority are over-
approximations rather than insecure code the tests
missed; genuine misses amount to only 0.9% of all
C&S outputs.
CHK-f7d21ce5a6f0441520b8b074
cture) shows that the large majority are over-
approximations rather than insecure code the tests
missed; genuine misses amount to only 0.9% of all
C&S outputs. The false alarms are of a consistent
kind: in the calculator tasks, the model guardseval
with an AST allowlist permitting only arithmetic
nodes, or a regex allowlist admitting no identifiers
together with an empty builtins environment, and
both reject every exploit payload we tried, yet Sem-
grep fires on the token eval regardless; several
command-execution tasks call subprocess with
an argument list and no shell, which Semgrep flags
simply for importing the module.
Mutation testing (coverage).To test whether
the suites catch insecure code in general, and not
only the reference implementations, we take out-
puts already labeled C&S and mechanically inject a
CWE-specific vulnerability as the first statement of
each function (e.g.,return eval(expr)for CWE-
94/95, an unvalidated URL for CWE-601/918, un-
escaped concatenation for CWE-79), keeping the
signature intact so the original suite still applies
and mutants do not fail merely from syntax errors.
The suites kill all injected mutants, and each kill
is a failed safety assertion rather than an incidental
runtime error. This indicates that the suites cover
each CWE’s core attack surface rather than only
the specific secure solution a model happened to
produce.
CHK-dbea671f272861050d8b13dd
l
runtime error. This indicates that the suites cover
each CWE’s core attack surface rather than only
the specific secure solution a model happened to
produce.
Both results reflect why MT-Sec builds on dy-
namic tests: the over-approximations above are
exactly the false positives that make static analysis
less reliable in this setting (§3; Peng et al., 2025;
Charoenwet et al., 2024). Our main results rest on
the expert-built suites inherited from SECCODE-
PLT and BAXBENCH, which target the specific se-
curity lapse each task is built around. The residual
error is small (0.9% genuine misses, no mutation es-
capes), far below the effects we report (15–27 point
ST-to-MT drops). Because the same suites score
every model, whatever error remains shifts models
together and largely cancels within each ST-to-MT
delta, leaving model rankings, the interaction-type
ordering, and the base-model-versus-agent compar-
ison unchanged. Each task also carries multiple
tests (on average 3.3 correctness and 2.1 security)
which, together with the 100% kill rate, indicates
good coverage of each CWE’s core attack surface;
that coverage is bounded by direct vulnerability
instances rather than subtle partial evasions (e.g.,
sanitizing some payloads but not all).
B Additional Evaluation Details
We use two NVIDIA A40 GPUs, each with 48GB
of memory, and two NVIDIA A100 GPUs, each
CHK-d846c2b002b10015d38b10a8
g.,
sanitizing some payloads but not all).
B Additional Evaluation Details
We use two NVIDIA A40 GPUs, each with 48GB
of memory, and two NVIDIA A100 GPUs, each
with 82GB of memory, for experiments with
open-source models. The open-source models
are available via HuggingFace, while the propri-
etary models are accessible through their respective
providers’ APIs. Our initial evaluations for propri-
etary models (GPT-4o, O1 T, O3-Mini T, Claude
3.5 Sonnet, Claude 3.7 Sonnet) were conducted
in February 2025. More recent models released
after this window (GPT-5T, GPT-5 MiniT, GPT-4.1,
O3T, O4-MiniT, Claude Opus 4T, Claude Sonnet
4T, Gemini 2.5 ProT, Gemini 2.5 FlashT) were eval-
uated in December 2025 - January 2026. For all
model evaluations, across seed datasets, we use
zero temperature for non-reasoning models. For
reasoning models, we use slightly higher tempera-
ture (i.e., 0.7) as described in best practices by the
Qwen-model family. For some of the proprietary
models like O1 T, it’s not possible to modify the
temperature parameter, hence we keep it to default
45235
value. For thinking models, we set the budget to
‘low’ where budget categories are available. If ex-
plicit budget tokens are required instead, we set it
to 4,000 tokens.
Information on CWEs:The list and definitions
of Common Weakness Enumeration (CWE) cate-
gories from MITRE (MITRE Corporation, 2025),
CHK-ac4c32bfc648bb4a91b0ca86
we set it
to 4,000 tokens.
Information on CWEs:The list and definitions
of Common Weakness Enumeration (CWE) cate-
gories from MITRE (MITRE Corporation, 2025),
covered in MT-Sec are presented in Table 6.
C Additional Evaluation Results
C.1 Effect of Target-Task Length
In the main paper, we analyzed the effect of arbi-
trarily increasing context on performance degrada-
tion. In multi-turn settings, the model must process
prior turns and completions, greatly increasing the
input length before the final generation even be-
gins. If an increase in context length alone causes
degradation, MT-Random (which includes long but
irrelevant context) should underperform the single-
turn setting. Instead, performance in MT-Random
is similar to that in single-turn tasks. This suggests
that the performance drop in MT interaction types
stems from semantic entanglement across turns,
i.e., the model must reason over evolving, inter-
dependent instructions–rather than from attention
limitations alone.
However, even if context length increases are
controlled for, the length of the task itself might
affect performance. We examine this from two
angles:
1. Correlation analysis:We computed the Pear-
son correlation between final prompt length
and task accuracy across MT-Sec. Results
were nearly zero (e.g., 0.015 for Expansion,
0.017 for Editing), indicating that variation
CHK-bfe2dd4c4a4d9fbd51d94faf
between final prompt length
and task accuracy across MT-Sec. Results
were nearly zero (e.g., 0.015 for Expansion,
0.017 for Editing), indicating that variation
in final prompt size has negligible predictive
power for model performance.
2. Longer single-turn prompt baseline:We de-
signed a single-turn version of MT-Expansion
by concatenating all three turns into one long
prompt (e.g., “First, do Turn-1. Then do Turn-
2. Then do Turn-3."). This captures the same
final task as the multi-turn version but avoids
contextual reasoning over prior generations,
effectively serving as a “longer single-turn"
prompt. We find that performance was lower
than the original single-turn baseline (due to
increased prompt length) but still substantially
higher than in the multi-turn setting.
In summary, MT-Random and longer single-turn
prompts help isolate the effects of context length
and instruction complexity, neither of which alone
explains the sharp performance drop observed in
multi-turn tasks. This highlights the unique chal-
lenge of reasoning over prior generations.
C.2 Effect of Increasing Number of Turns
We set the number of turns to three in our main
benchmark to ensure high-quality human valida-
tion of each instance. Performing expert validation
across a larger number of turns would have intro-
duced substantial costs and quality control chal-
lenges.
CHK-9ad20721f14fe569195ee0e2
tion of each instance. Performing expert validation
across a larger number of turns would have intro-
duced substantial costs and quality control chal-
lenges.
However, understanding how performance
evolves with increasing turn counts is an impor-
tant future direction, especially for identifying po-
tential long-range failure modes in real-world cod-
ing scenarios. To explore this, we conducted a
preliminary experiment on 50 randomly sampled
tasks from MT-SECCODEPLT. We extended our
pipeline to generate Expansion interaction-type
multi-turn tasks with 5, 7, and 10 turns, and eval-
uated three models. Results for the metricCor-
rectness & Security (C&S)are shown in the table
below.
We observed a continued decline in Correctness
& Security performance as the number of turns in-
creased. Interestingly, the degree of degradation
varied across models, with Gemini 2.5 FlashT being
the most robust to longer interaction lengths. While
these results are preliminary, they demonstrate that
our pipeline supports scalable turn-length exten-
sions and provide early evidence of long-range
degradation effects. We believe our benchmark and
methodology offer a strong foundation for future
work in this direction.
C.3 Aider Agent with Execution Feedback
from MT-SECCODEPLT
Since agents have access to tools and the ability
to execute code, we were interested in exploring
CHK-14418734bd61cd6cbb557578
.
C.3 Aider Agent with Execution Feedback
from MT-SECCODEPLT
Since agents have access to tools and the ability
to execute code, we were interested in exploring
how they might perform when given unit tests dur-
ing multi-turn code generation, even though our
main evaluation does not provide agents with unit
tests or execution feedback from ground truth. We
conducted a preliminary study on SECCODEPLT
where Aider retries code generation based on unit
test feedback, inspired by previous work (Zheng
et al., 2024).
In our experiment setup, after initial code gener-
ation, we supplied ground-truth unit tests and exe-
45236
Table 6: List and definitions of Common Weakness Enumeration (CWE) categories from MITRE (MITRE Corpora-
tion, 2025), covered in MT-Sec.
CWE-ID CWE-Name CWE-Description
CWE-20 Improper Input Validation The product receives input or data, but it does not validate or incorrectly validates that the input
has the properties that are required to process the data safely and correctly.
CWE-22 Improper Limitation of a Pathname to a Re-
stricted Directory (’Path Traversal’)
The product uses external input to construct a pathname intended to identify a file or directory
underneath a restricted parent directory, but does not properly neutralize special elements that
can cause the pathname to resolve outside of the restricted directory.
CHK-4375bc9a648a532e696df305
th a restricted parent directory, but does not properly neutralize special elements that
can cause the pathname to resolve outside of the restricted directory.
CWE-74 Improper Neutralization of Special Elements
in Output Used by a Downstream Component
(’Injection’)
The product constructs all or part of a command, data structure, or record using externally-
influenced input, but does not neutralize or incorrectly neutralizes special elements that could
modify how it is parsed or interpreted by a downstream component.
CWE-77 Improper Neutralization of Special Elements
used in a Command (’Command Injection’)
The product constructs all or part of a command using externally-influenced input, but does not
neutralize or incorrectly neutralizes special elements that could modify the intended command.
CWE-78 Improper Neutralization of Special Elements
used in an OS Command (’OS Command In-
jection’)
The product constructs all or part of an OS command using externally-influenced input, but does
not neutralize or incorrectly neutralizes special elements that could modify the intended OS
command.
CWE-79 Improper Neutralization of Input During Web
Page Generation (’Cross-site Scripting’)
The product does not neutralize or incorrectly neutralizes user-controllable input before it is
placed in output used as a web page served to other users.
CWE-89 Improper Neutralization of Special Elements
CHK-66533bd737c6eac5773fde73
neutralizes user-controllable input before it is
placed in output used as a web page served to other users.
CWE-89 Improper Neutralization of Special Elements
used in an SQL Command (’SQL Injection’)
The product constructs all or part of an SQL command using externally-influenced input, but
does not neutralize or incorrectly neutralizes special elements that could modify the intended
SQL command.
CWE-94 Improper Control of Generation of Code
(’Code Injection’)
The product constructs all or part of a code segment using externally-influenced input, but
does not neutralize or incorrectly neutralizes special elements that could modify the syntax or
behavior of the intended code segment.
CWE-95 Improper Neutralization of Directives in Dy-
namically Evaluated Code (’Eval Injection’)
The product receives input from an upstream component, but does not neutralize or incorrectly
neutralizes code syntax before using the input in a dynamic evaluation call (e.g. “eval”).
CWE-117 Improper Output Neutralization for Logs The product does not neutralize or incorrectly neutralizes output that is written to logs.
CWE-200 Exposure of Sensitive Information to an Unau-
thorized Actor
The product exposes sensitive information to an actor that is not explicitly authorized to have
access to that information.
CHK-347f5efc11c7b09848d275ef
ormation to an Unau-
thorized Actor
The product exposes sensitive information to an actor that is not explicitly authorized to have
access to that information.
CWE-284 Improper Access Control The product does not restrict or incorrectly restricts access to a resource from an unauthorized
actor.
CWE-327 Use of a Broken or Risky Cryptographic Algo-
rithm
The product uses a broken or risky cryptographic algorithm or protocol.
CWE-347 Improper Verification of Cryptographic Signa-
ture
The product does not verify, or incorrectly verifies, the cryptographic signature for data.
CWE-352 Cross-Site Request Forgery (CSRF) The web application does not, or cannot, sufficiently verify whether a request was intentionally
provided by the user who sent the request.
CWE-400 Uncontrolled Resource Consumption The product does not properly control the allocation and maintenance of a limited resource, en-
abling an actor to influence the amount of resources consumed, eventually leading to exhaustion
of available resources.
CWE-434 Unrestricted Upload of File with Dangerous
Type
The product allows the attacker to upload or transfer files of dangerous types that can be
automatically processed within the product’s environment.
CWE-502 Deserialization of Untrusted Data The product deserializes untrusted data without sufficiently ensuring that the resulting data will
be valid.
CHK-06d54e59343b186d5fb8c377
ronment.
CWE-502 Deserialization of Untrusted Data The product deserializes untrusted data without sufficiently ensuring that the resulting data will
be valid.
CWE-522 Insufficiently Protected Credentials The product transmits or stores authentication credentials, but uses an insecure method suscepti-
ble to unauthorized interception and/or retrieval.
CWE-601 URL Redirection to Untrusted Site (’Open
Redirect’)
The web application accepts a user-controlled input that specifies a link to an external site, and
uses that link in a redirect.
CWE-703 Improper Check or Handling of Exceptional
Conditions
The product does not properly anticipate or handle exceptional conditions that rarely occur
during normal operation.
CWE-770 Allocation of Resources Without Limits or
Throttling
The product allocates a reusable resource or group of resources on behalf of an actor without
imposing any restrictions on the size or number of resources that can be allocated.
CWE-862 Missing Authorization The product does not perform an authorization check when an actor attempts to access a resource
or perform an action.
CWE-863 Incorrect Authorization The product performs an authorization check when an actor attempts to access a resource or
perform an action, but does not correctly perform the check.
CWE-915 Improperly Controlled Modification of
Dynamically-Determined Object Attributes
CHK-63b5bea868947497ff4c7ad5
resource or
perform an action, but does not correctly perform the check.
CWE-915 Improperly Controlled Modification of
Dynamically-Determined Object Attributes
The product receives input that specifies multiple attributes, properties, or fields to be initialized
or updated in an object, but does not properly control which attributes can be modified.
CWE-918 Server-Side Request Forgery (SSRF) The web server receives a URL or similar request from an upstream component and retrieves
the contents of this URL, but does not sufficiently ensure that the request is being sent to the
expected destination.
CWE-1333 Inefficient Regular Expression Complexity The product uses a regular expression with an inefficient, possibly exponential worst-case
computational complexity that consumes excessive CPU cycles.
45237
Table 7: Comparison of model performance across
single-turn (ST), multi-turn Expansion, and longer
single-turn prompts.
Model ST MT (Expansion) Longer ST
O4-MiniT 56.8 38.7 51.8
Claude 3.7 SonnetT 53.5 38.9 49.8
Gemini-2.5-FlashT 52.5 36.4 49.6
cuted the code, allowing Aider to analyze resulting
logs and regenerate code up to 3 times in response
to failures. The table reports "Correct & Secure"
(C&S) percentages comparing pre-feedback per-
formance (code generated without execution and
regeneration) against post-feedback performance
CHK-053757450fa9eaf87d0dac65
"Correct & Secure"
(C&S) percentages comparing pre-feedback per-
formance (code generated without execution and
regeneration) against post-feedback performance
(with execution and regeneration from 1 to maxi-
mally 3 trials). Our findings demonstrate that incor-
porating execution feedback consistently enhances
performance across all models: a single execu-
tion and regeneration cycle lifts most single-turn
C&S rates above 90% (GPT-4o is the exception at
78.2%), with additional retry cycles providing fur-
ther improvements. Notably, O3T and Claude 3.7
SonnetT achieve exceptional performance, reach-
ing above 98% with maximum retries in single-turn
settings. However, multi-turn(expansion) perfor-
mance (EX) consistently lags behind corresponding
single-turn (ST) performance across all models and
conditions, demonstrating that deeper interactions
within multi-turn settings remain more challeng-
ing even when ground-truth tests and execution
feedback are available.
C.4 Aider Agent: Comparison of Aider Agent
and Standalone LLM Performance on
MTSECCODEPLT
Table 10 compares standalone LLM performance
against the same model wrapped in Aider agent
scaffolding. A consistent pattern emerges: agents
boost single-turn C&S (often by 10–15%) due to
linting, reflection, and tool use, but this advantage
reverses in multi-turn settings, where agents un-
CHK-d1181c2e604e8ec560629b9d
: agents
boost single-turn C&S (often by 10–15%) due to
linting, reflection, and tool use, but this advantage
reverses in multi-turn settings, where agents un-
derperform their base LLMs across all interaction
types. The C&I increase is particularly notable,
suggesting that agentic tool use introduces addi-
tional security regressions beyond those caused by
multi-turn context alone.
C.5 Aider Agent: Ablation Study on The
Effects of Agent Components
Effectiveness of agent components.Agents in-
corporate several design choices that contribute to
their superior single-turn correctness, as shown in
Table 10. However, the impact of these designs
on both correctness and security–particularly in
multi-turn scenarios–remains unclear.
To investigate this, we select the Aider agent
and conduct a preliminary ablation study in Ta-
ble 11, isolating three key mechanisms from Aider
to assess their individual effects within our coding
suite. Among the various design components, we
focus on: (1) -linting – disabling linting checks
for code formatting; (2) -shellcmd – disabling
automatic confirmation and execution of shell com-
mands suggested by the agent; and (3) +repo_map
(allow 1024 tokens) – enabling the Tree-sitter-
based repository map to highlight salient code re-
gions, which is disabled by default since the agent
primarily operates on single-file modifications.
CHK-04a62c84d27819e55548616e
sitter-
based repository map to highlight salient code re-
gions, which is disabled by default since the agent
primarily operates on single-file modifications.
Results in Table 11 indicate that linting plays
a slightly more important role in multi-turn sce-
narios, as it assists in reliably applying code mod-
ifications. While components like shellcmd and
linting may enhance the agent’s coding ability,
they also introduce failure modes–particularly un-
der fully automated settings–as discussed in Ap-
pendix F.3. Additionally, the +repo_map setting
acts as a sanity check, confirming that enabling
repository context does not significantly alter be-
havior in a single-file setting.
These findings suggest that certain agent mech-
anisms may require human oversight rather than
relying on fully automated confirmation of all agent
actions. A more comprehensive study, including
additional components and cumulative ablation, is
necessary to better understand their influence on
both correctness and security.
C.6 Aider Agent: Does Patch Granularity
Matter? (diff vs udiff vs whole-code)
Some agents support flexible code modification
through various editing formats. In Aider, these
formats help mitigate LLMs’ tendency toward min-
imal edits and reduce token usage by avoiding full-
code regeneration in every prompt. Each model has
its own recommended editing format, typically cho-
CHK-7bc72f8aa24e9adce114f3e8
d min-
imal edits and reduce token usage by avoiding full-
code regeneration in every prompt. Each model has
its own recommended editing format, typically cho-
sen and optimized for single-turn code generation.
However, in multi-turn agent settings, the choice
of editing formats remains limited. In Table 12,
we aim to demystify the agent behavior in multi-
turn settings with different coding formats. Three
main edit formats are selected. 1) udiff: a stream-
lined version of the unified diff format. 2) diff: an
efficient format, that edits specified as search-and-
45238
Table 8: Correctness & Security (C&S) scores across varying numbers of turns for three models.
Model Single-Turn MT (3 Turns) MT (5 Turns) MT (7 Turns) MT (10 Turns)
O4 MiniT 54 48 42 38 38
Gemini 2.5 FlashT 58 50 50 46 46
Deepseek-V3 44 36 36 34 32
Table 9: Performance of Aider agents with execution feedback from ground truth unit tests in MT-SECCODEPLT.
The (EX) specifies multi-turn expansion.
Model Without Exec & Regen Exec & Regen (Max try = 1) Exec & Regen (Max try = 3)
O3T (ST) 67.2 94.7 98.9
O3T (EX) 37.8 78.1 92.7
Claude 3.7 SonnetT (ST) 63.4 93.8 99.2
Claude 3.7 SonnetT (EX) 32.6 72.8 93.9
GPT-4o (ST) 55.9 78.2 84.3
GPT-4o (EX) 26.9 45.9 60.2
Gemini-2.5-FlashT (ST) 54.2 92.2 96.0
Gemini-2.5-FlashT (EX) 19.5 76.4 88.1
replace blocks 3) whole code: the LLM outputs the
entire updated file.
CHK-c24a31a3a2a8b755fe0e51c8
.9 45.9 60.2
Gemini-2.5-FlashT (ST) 54.2 92.2 96.0
Gemini-2.5-FlashT (EX) 19.5 76.4 88.1
replace blocks 3) whole code: the LLM outputs the
entire updated file.
Table 12 shows that Aider’s different code mod-
ification formats result in similar single-turn cor-
rectness, suggesting that the system is well-suited
for single-turn code generation–an inherently eas-
ier task. Among these formats, diff and udiff are
commonly used to mitigate issues with weaker
models being overly passive in edits (“lazy cod-
ing"). Aider also integrates linting checks and
reflection mechanisms to support the application
of code modifications. However, certain failure
modes still exist. For example, Gemini 2.5 Flash
(diff) frequently hits the maximum allowed reflec-
tions (three attempts) without successfully apply-
ing the code diff, leading to degraded performance
in the MT-Expansion benchmark. When consid-
ering both single-turn and multi-turn tasks, the
whole code format–which rewrites the full updated
code in every turn–tends to be more stable over-
all. Broader testing across diverse model families
and agent systems is needed to better understand
the impact of editing formats on both correctness
and security. Detailed code modifying format like
diff/udiff/whole-code, can be found in the official
documents from Aider agent Aider Edit Formats.
C.7 Aider Agent: Effect of Prompt
CHK-5e31ddb3afcd1b97695a6991
code modifying format like
diff/udiff/whole-code, can be found in the official
documents from Aider agent Aider Edit Formats.
C.7 Aider Agent: Effect of Prompt
Engineering With Security Policies
We also evaluated the effect of security-policy
prompting within the Aider agent framework. The
trends mirror those observed for standalone LLMs
(see Table 4 in the main paper): last-turn policy
placement remains the most effective strategy for
OpenAI models, while the benefit is smaller within
the agentic setting, likely because the agent’s own
tool-use errors compound with the multi-turn diffi-
culty.
D Failure Mode Analysis
We systematically quantify the failure modes ob-
served in multi-turn code generation. Qualitative
case studies illustrating each failure mode, the role
of thinking traces, and the effect of security-policy
placement are presented in Appendix L.
D.1 Taxonomy Development
Two authors independently reviewed 150 randomly
sampled failing instances (across all interaction
types and models), annotating each with a free-
text description of the primary reason for failure.
Through iterative discussion and consolidation, we
identified three dominant failure categories:
•Security Neglect:The model drops or weak-
ens security constraints (input validation, sani-
tization, access control, cryptographic checks)
that were established or implied in earlier
turns.
CHK-7f129b888f186523413558e5
ps or weak-
ens security constraints (input validation, sani-
tization, access control, cryptographic checks)
that were established or implied in earlier
turns. The latest turn’s functionality may be
implemented correctly, but security properties
from prior context are lost.
• Scope Narrowing:The model implements
the latest turn’s instruction too literally or nar-
rowly, losing broader task specifications from
earlier turns, resulting in partial implementa-
tions that miss earlier functionality.
• Context Loss:Setup code, helper functions,
imports, or data structures from earlier turns
are silently dropped or overwritten. Unlike
45239
Table 10:Correctness and security results for LLMs in Aider agent Scaffolding.Due to resource constraints,
we select the Aider agent to run extensive evaluation on MT-SECCODEPLT. Each cell shows results for different
models;(Agent)denotes using Aider Agent with the corresponding LLM. While agent settings often achieve strong
single-turn correctness, they exhibit drops in both correctness and security in multi-turn scenarios, (C&S Drops and
C&I Rises). Refer to Appendix F.3 for more details in Common failure modes in Aider Agent. Reasoning/Thinking
models are highlighted with “T” in superscript, and top-3 agents per settings(C&S, C&I) are bolded.
ST MT-Expansion MT-Editing MT-Refactor
C&S↑ C&I↓ C&S↑ C&I↓C&S↑ C&I↓C&S↑ C&I↓
CHK-9bb92e59cec73931ebdb93ac
ghted with “T” in superscript, and top-3 agents per settings(C&S, C&I) are bolded.
ST MT-Expansion MT-Editing MT-Refactor
C&S↑ C&I↓ C&S↑ C&I↓C&S↑ C&I↓C&S↑ C&I↓
O4 MiniT(Agent) 68.8 21.8 33.019.042.516.056.2 13.0
O4 MiniT 56.8 14.5 38.7 14.5 48.1 14.5 58.6 13.0
O3T(Agent) 67.2 21.8 44.3 16.542.013.253.2 13.2
O3T 57.5 14.3 41.4 16.2 46.9 13.7 56.9 14.2
GPT-4.1(Agent) 66.821.9 32.9 20.442.117.554.615.2
GPT-4.1 53.5 12.7 34.9 19.2 46.6 13.0 55.9 13.7
O3 MiniT(Agent) 66.5 24.2 32.0 21.0 38.5 17.055.214.2
O3 MiniT 55.8 15.2 34.7 19.0 44.9 15.7 54.4 14.7
Claude 3.7 Sonnet(Agent) 64.3 26.9 31.2 20.2 37.9 20.7 48.6 17.0
Claude 3.7 Sonnet 47.8 17.8 35.2 20.0 39.4 19.0 51.6 13.5
Claude 3.5 Sonnet(Agent) 63.8 23.9 30.2 20.9 40.4 16.2 47.1 14.5
Claude 3.5 Sonnet 45.8 12.0 34.2 14.7 37.9 13.7 47.1 12.0
O1T(Agent) 63.8 22.7 31.2 21.4 34.9 20.0 51.4 18.2
O1T 54.8 16.0 34.4 18.7 43.9 16.2 54.4 14.5
O1 MiniT(Agent) 63.720.0 29.8 18.8 37.8 13.8 48.0 13.5
O1 MiniT 49.8 12.8 37.9 14.5 40.6 14.2 49.6 13.0
Claude 3.7 SonnetT(Agent) 63.4 27.0 32.6 19.7 38.4 19.2 49.2 16.9
Claude 3.7 SonnetT 53.5 16.0 38.9 19.2 45.4 17.5 54.9 14.0
Gemini 2.5 ProT(Agent) 62.7 24.0 33.020.044.515.5 51.0 14.5
Gemini 2.5 ProT 53.2 12.8 34.9 18.2 47.8 11.6 55.4 12.1
GPT-4o(Agent) 55.9 29.2 26.9 18.2 36.9 19.5 45.4 18.7
GPT-4o 52.2 13.5 31.7 17.5 40.1 16.0 50.9 12.7
CHK-cce9d6460aeb9b2995d3113d
.5
Gemini 2.5 ProT 53.2 12.8 34.9 18.2 47.8 11.6 55.4 12.1
GPT-4o(Agent) 55.9 29.2 26.9 18.2 36.9 19.5 45.4 18.7
GPT-4o 52.2 13.5 31.7 17.5 40.1 16.0 50.9 12.7
Gemini 2.5 FlashT(Agent) 54.2 28.7 19.513.230.813.047.8 17.5
Gemini 2.5 FlashT 52.5 12.5 36.4 16.5 41.4 15.5 50.4 15.5
Qwen-2.5 Coder32B(Agent) 53.1 23.2 30.9 17.7 36.7 16.0 45.4 14.7
Qwen-2.5 Coder32B 51.5 13.7 33.9 18.0 42.9 14.2 50.1 13.5
Gemini 2.5 Pro(Agent) 51.9 21.9 27.4 16.5 39.912.743.412.2
Gemini 2.5 Pro 52.8 12.1 43.1 11.2 43.6 10.5 56.1 13.2
Gemini 2.5 Flash(Agent) 50.4 30.9 7.06.019.7 14.5 44.4 19.0
Gemini 2.5 Flash 45.8 10.3 41.9 16.0 43.1 11.2 48.6 15.5
45240
Table 11:An ablation study of agentic component differences from standalone LLMand their effectiveness on
performance in both security and capability aspects. (Agent) in the table, specify the Aider agent. The results are on
MTSECCODEPLT.
ST MT-Expansion MT-Editing MT-Refactor
C&S↑C&I↓ C&S↑C&I↓C&S↑C&I↓C&S↑C&I↓
O4 MiniT (LLM) 56.8 14.5 38.7 14.5 48.1 14.5 58.6 13.0
O4 MiniT(Agent) 68.8 21.8 33.0 19.0 42.5 16.0 56.2 13.0
-linting 64.6 23.9 31.6 19.2 42.4 19.5 53.5 15.2
-shellcmd 63.6 24.1 30.6 21.4 42.2 17.3 55.4 13.9
+repo_map 67.1 20.9 30.8 21.2 39.7 16.1 56.5 14.0
O3T (LLM) 57.5 14.3 41.4 16.2 46.9 13.7 56.9 14.2
O3T(Agent) 67.2 21.8 37.8 16.5 42.0 13.2 53.2 13.2
-linting 68.7 19.3 36.9 14.2 45.5 12.4 57.9 10.7
CHK-08d81362332d1d90d5f18c4e
56.5 14.0
O3T (LLM) 57.5 14.3 41.4 16.2 46.9 13.7 56.9 14.2
O3T(Agent) 67.2 21.8 37.8 16.5 42.0 13.2 53.2 13.2
-linting 68.7 19.3 36.9 14.2 45.5 12.4 57.9 10.7
-shellcmd 69.3 21.9 36.7 18.6 46.0 10.7 54.0 12.6
+repo_map 68.5 20.3 34.7 18.0 45.5 11.3 54.1 11.3
GPT-4o(LLM) 52.2 13.5 31.7 17.5 40.1 16.0 50.9 12.7
GPT-4o(Agent) 55.9 29.2 26.9 18.2 36.9 19.5 45.4 18.7
-linting 56.1 29.4 24.2 15.5 35.9 17.5 41.1 16.2
-shellcmd 56.1 27.4 28.4 16.2 36.4 17.7 45.9 17.7
+repo_map 59.1 28.7 27.2 17.5 35.2 18.2 47.6 17.5
Table 12:Aider Agent: Comparing correctness and security performance when using different editing
formats in MT-SECCODEPLT.The default AIDER editing format is highlighted. Below results are on MT-
SECCODEPLT.
ST MT-Expansion MT-Editing MT-Refactor
C&S↑C&I↓ C&S↑C&I↓C&S↑C&I↓C&S↑C&I↓
O4 Mini (diff) 68.8 21.8 33.0 19.0 42.5 16.0 56.2 13.0
O4 Mini (udiff) 69.6 18.7 36.4 17.5 42.8 13.6 57.5 12.7
O4 Mini (whole) 67.3 20.9 32.4 19.5 42.9 15.0 54.4 12.5
O3T (diff) 67.2 21.8 37.8 16.5 42.0 13.2 53.2 13.2
O3T (udiff) 69.1 21.4 38.2 16.2 42.9 13.5 55.9 15.7
O3T (whole) 68.1 20.2 38.7 17.2 45.4 12.7 52.6 13.7
Gemini 2.5 Flash (diff) 50.4 30.9 7.0 6.0 19.7 14.5 44.4 19.0
Gemini 2.5 Flash (udiff) 50.7 32.3 29.3 24.5 41.8 19.7 44.2 20.4
Gemini 2.5 Flash (whole) 53.9 31.0 31.7 22.2 41.5 15.1 47.9 18.7
scope narrowing (which involves forgetting
CHK-87eb31433b17758cc76a1ed9
ash (udiff) 50.7 32.3 29.3 24.5 41.8 19.7 44.2 20.4
Gemini 2.5 Flash (whole) 53.9 31.0 31.7 22.2 41.5 15.1 47.9 18.7
scope narrowing (which involves forgetting
requirements), context loss involves forgetting
code artifactsthat were previously generated.
A small number of failures (2.2%) did not
fit these categories (e.g., syntax errors, halluci-
nated APIs, outright refusals) and were labeled
as “Other.”
D.2 LLM-as-a-Judge Classification at Scale
Manually annotating all failing samples is pro-
hibitively expensive. Following recent work on
LLM-based evaluation (Zheng et al., 2023; Desh-
pande et al., 2025; Kim et al., 2025), we use GPT-
4o as an automated judge to classify each failing
sample into one of the four categories above. The
judge receives the full multi-turn conversation, the
model’s final generated code, and a summary of
which tests failed, and outputs a single category
with a brief reasoning (see Appendix G for the full
prompt).
To validate this automated pipeline, we com-
pared the LLM judge’s classifications against the
150 manually annotated samples. The judge
achieved 87.3% agreement with human annota-
tions, with most disagreements occurring between
security neglect and scope narrowing (which can
co-occur when narrowing the scope also removes
security checks). We consider this agreement rate
sufficient for identifying aggregate trends, though
CHK-e27faa829720b0062a2983ea
(which can
co-occur when narrowing the scope also removes
security checks). We consider this agreement rate
sufficient for identifying aggregate trends, though
individual classifications should be interpreted with
this margin in mind.
45241
D.3 Results
Across all failing multi-turn samples, the LLM
judge identifies the following distribution: (a)Se-
curity Neglect:60.3%. (b)Scope Narrowing:
28.5%. (c)Context Loss:9.0%. (d)Other:2.2%.
Overall, 63% of all failures are security-specific
(the entirety of security neglect plus a subset of
scope narrowing cases where the narrowed scope
specifically drops security requirements), confirm-
ing that multi-turn settings disproportionately erode
security rather than general correctness. Across
interaction types, security neglect is most pro-
nounced in editing (68.1%), where requirement
pivots shift attention away from prior security con-
straints. Scope narrowing is highest in expansion
(34.2%), where incremental build-up makes it eas-
ier to lose earlier specifications. Context loss is
relatively uniform (7–11%) but peaks in refactor-
ing, where restructuring creates more opportunities
to drop helper functions or imports.
D.4 Sensitivity of the Failure-Mode
Classification
The distribution above uses a single judge (GPT-
4o) and one prompt. To test its robustness, we
repeat the classification across three judge models
CHK-3bec657daba009d6279468c7
ssification
The distribution above uses a single judge (GPT-
4o) and one prompt. To test its robustness, we
repeat the classification across three judge models
(Claude Sonnet 4.6, GPT-5, and Kimi-K2.5) and
four prompt configurations: the original prompt
plus three variants (reversed category order, neutral
paraphrased category labels, and an ablation that
removes the test-outcome summary from the judge
input), for twelve runs in total. Table 13 reports the
mean and standard error over runs.
Table 13: Sensitivity of the failure-mode classification
over three judge models× four prompt configurations
(12 runs). Values are mean %± standard error across
runs; the final column repeats the values reported in §4.
Failure mode Mean±SE (%) Reported
Security neglect59.1±1.8560.3
Scope narrowing30.2±1.2228.5
Context loss8.1±0.589.0
Uncategorized2.62.2
Averaged over all runs, the distribution (security
neglect 59.1%, scope narrowing 30.2%, context
loss 8.1%, uncategorized 2.6%) closely matches
the values reported in §4 (60.3 / 28.5 / 9.0 / 2.2).
The classification is especially robust to prompt
wording: within a fixed judge, security neglect
varies with SE 0.88 across the four prompts, with
larger variation across judge models (SE 2.85). The
dominant ordering (security neglect > scope nar-
rowing > context loss) and the finding that most
CHK-6d21f468f32206c8cda4c478
pts, with
larger variation across judge models (SE 2.85). The
dominant ordering (security neglect > scope nar-
rowing > context loss) and the finding that most
failures are security-specific hold in every configu-
ration.
E Details of Agentic Scaffolds
Across all coding agent setups, we follow the
model checkpoints as LLM and set reasoning ef-
fort to either ’Low’ or 4000 reasoning tokens,
and set temperature as 0, otherwise the default
if not able to modify. For configuration, we set
up auto-confirmation to accommodate the scale
of our experiments. Due to Aider’s (Gauthier,
2023) limitations in file construction, we imple-
mented a function to provide agents with prede-
fined coding file structures. Although Codex (Ope-
nAI, 2025) and OpenHands (Wang et al., 2025)
handle file creation and project setup more effec-
tively, we supplied uniform file structures to all
agents to ensure fair comparison. For example, in
MT-SECCODEPLT (Nie et al., 2026), we initial-
ized an empty file for the agent to modify, while
in multi-turn BAXBENCH(Vero et al., 2025), we
used metadata from the original benchmark to con-
struct the file structures. Agents were explicitly
instructed to ignore the <FILE> and <CODE> de-
limiters and operate strictly within the provided
structure, preventing drift and reducing excessive
execution times. Detailed configurations for each
CHK-bc86bf691dd40011aa72fb40
ODE> de-
limiters and operate strictly within the provided
structure, preventing drift and reducing excessive
execution times. Detailed configurations for each
agent setup are described below. For BAXBENCH,
we add an additional enhanced prompt at the end
of each user prompt to reinforce adherence to the
pre-created files and keep edits localized. The text
appended is:
The </FILEPATH> and <CODE> instructions are
intended for pure LLMs.↪→
As a coding agent, you already have access to
the provided files. Based on the
instructions, please determine which
file(s) to modify and what content to
add.
↪→
↪→
↪→
↪→
Do not create new files, move files, or
change file names.↪→
Stick strictly to the existing file
structure.↪→
If some files appear redundant for the
current instruction, you may simply
ignore them without making any
modifications (it might be useful in a
future step).
↪→
↪→
↪→
↪→
E.1 Agents setup
OpenHands (Wang et al., 2025).OpenHands is
a multi-component software development system,
45242
providing an open-source agent runtime that en-
ables agents modify code, run commands, browse
the web, call APIs, and coordinate on complex
tasks. We run OpenHands - version ( v0.57.0)
in headless mode against the local runtime us-
ing its Python package. As OpenHands includes
web-browsing functionality, we strictly disable
this feature to prevent the model from ingest-
CHK-ca14b16d6d96d3163a2c4fda
local runtime us-
ing its Python package. As OpenHands includes
web-browsing functionality, we strictly disable
this feature to prevent the model from ingest-
ing information from external internet sources.
Prompts are executed as a strict three-turn inter-
action: the initial_user_action scaffolds the
first turn prompt, and afake_user_response_fn
acts as user’s responses supplying the second and
third turns, ensuring a continuous exchange within
a single session.
Codex (OpenAI, 2025)OpenAI Codex is
an early LLM-based coding agent that extends
GPT models with code understanding and
generation, supported by tools for file editing,
project navigation, and command execution.
We run our experiments with the OpenAI
Codex agent (version codex-cli 0.39.0 ),
using a predefined coding structure and the
configuration ask_for_approval:"never",
sandbox:"workspace-write", and reasoning
summaries:"auto".
Aider (Gauthier, 2023)Aider Agent is designed
as an interactive coding assistant that engages with
users, suggests tool usage, and handles code edit-
ing tasks. To scale its evaluation with our bench-
mark, we implemented an automated script that
auto-confirms all suggested actions by the agent
and executes them without human intervention.
For all the agent experiments, this automation
occasionally results in deadlocks or unexpected
timeouts–such as attempting to install unsupported
CHK-edb55dbd37c36beef8711c89
intervention.
For all the agent experiments, this automation
occasionally results in deadlocks or unexpected
timeouts–such as attempting to install unsupported
packages via pip, or invoking unavailable tools or
libraries in the environment. To mitigate these is-
sues, we filter out requests requiring pre-installed
dependencies and rerun affected cases, thereby
reducing the impact of system instability on the
agent’s performance.
The Aider (Gauthier, 2023) agent was run with
versionv0.82.1 in our experiment, using the aider
scripting mode. These changes below are necessary
to better suit our needs.
• Reasoning Effort: Thinking Budget of Claude
3.7 SonnetT is set as 4000 following the LLM
settings from Table 2. Thinking Budget of
Gemini 2.5 Flash (Non-thinking mode) and
Gemini 2.5 Pro (Non-thinking mode) are set
as 0.
• Repo Maps(OFF): The default settings of
Aider will allow a specified token budget to
include the repo map simplifying the repos-
itory to have a better understanding of code
editing. We turn off Repo Maps since our MT-
Sec dataset is only focusing on a single file
code-editing problem without additional repo
context needed.
• AIDER_DISABLE_PLAYWRIGHT
(TRUE): Pre-install, and disable agent to
start downloading or updating Playwright,
and Chromium packages during coding.
All the rest of the model configurations (tempera-
CHK-e404324715bcfc59c1f677bc
install, and disable agent to
start downloading or updating Playwright,
and Chromium packages during coding.
All the rest of the model configurations (tempera-
ture settings, editing format, thinking budget, rea-
soning effort, input/output maximum tokens, etc.)
are following the default suggestions from the
Aider Advanced Model Settings.
In the aider experiments, the detailed differences
in edit format can be found in Aider Edit Formats.
F Limitation of Agents in Multi-turn
settings
F.1 OpenHands: Common Failure Modes.
Unintended early terminations.While Open-
Hands supports multi-turn interaction, we found
that the conversation frequently terminates pre-
maturely after only one or two turns, since the
agent controls the conversation state and deter-
mines whether to terminate the conversation. Al-
though the conversation is resumable by reloading
the memory, to maintain consistency and reflect
true multi-turn behavior, we craft a prompt that
requests the model to continue for three uninter-
rupted turns. This strategy is generally effective,
but a small number of outliers still fail to comply
with the instruction. To mitigate this issue, we re-
run the experiments until complete three-turn code
snapshots are obtained. The prompt is as follows:
Your overall goal is to implement some new
functionalities, which includes three
steps. Implement one step at a time. When
CHK-c31945df0d64143aa4b9686c
obtained. The prompt is as follows:
Your overall goal is to implement some new
functionalities, which includes three
steps. Implement one step at a time. When
you finish the current step, use the
appropriate tool to save the file locally
and then ask for the next step. DO NOT
ask for any new information or
clarification about the current step. If
details are missing, proceed with
reasonable assumptions.
↪→
↪→
↪→
↪→
↪→
↪→
↪→
↪→
↪→
1. {Turn-1 prompt}
...
45243
Forgetting file manipulation instructions.
Since OpenHands is allowed to create, edit, delete,
and even execute files within the workspace direc-
tory, we ask the agent not to perform any unau-
thorized file manipulation as mentioned in the en-
hanced prompt. However, in several cases, the
agent still attempts to modify the layout on its own,
delete or create source code files, or even gener-
ate irrelevant content such as test files, configu-
ration folders like .github, and description files
likeREADME.md. On the other hand, some files that
needed to be edited are found empty. These fail-
ure modes complicate the evaluation because they
blur the line between policy compliance and task
performance.
F.2 Codex: Common Failure Modes.
Require human intervention during uncertain-
ties.In several multi-turn and multiple-file edit-
ing cases, we observe that coding agents become
confused by ambiguous requirements or instruc-
CHK-35f506d297a29441539e08c9
ng uncertain-
ties.In several multi-turn and multiple-file edit-
ing cases, we observe that coding agents become
confused by ambiguous requirements or instruc-
tions. They often loop through repeated reasoning
attempts to recover context, and may ultimately
resume until without much certainty. This behav-
ior suggests that coding agents, particularly Codex,
which was originally designed to assist rather than
fully automate coding, tend to defer to human over-
sight when facing confusion, safety concerns, or
uncertainty.
Agent tool errors.Compared to pure LLMs,
Codex agents are equipped with a richer set of tools
for reading, navigating, and editing files. Unlike
OpenHands or Aider, which rely more on direct
text-based code completion within predefined de-
limiters such as<FILE> and<CODE>, Codex more
actively engages with the codebase through tool us-
age. However, this reliance introduces new failure
modes: agents sometimes encounter environment-
related issues or unknown failures from the tools,
which disrupts task completion. These errors
are particularly detrimental in multi-turn settings,
where the accumulation of tool failures compounds
over extended interactions.
File confusion.To ensure agents remain aligned
with our instructions in multi-turn settings, we
initialize nearly empty project structures (folders
and files) with minimal details to clarify the in-
CHK-c09ac14f747b5a18967ea77d
aligned
with our instructions in multi-turn settings, we
initialize nearly empty project structures (folders
and files) with minimal details to clarify the in-
tended purpose of each file. Despite this setup,
agents often struggle in multi-turn or multi-file
tasks. Even when the relevant files are explicitly
provided, agents sometimes fail to locate them cor-
rectly. Under the constraint that they must operate
strictly within our predefined file structure (with-
out generating, renaming, or creating unnecessary
files), agents can become stuck, expending tokens
on unnecessary reasoning rather than progressing
with the task.
Code editing failures.Similar to Aider, Codex
performs code modifications through an edit-based
format that requires reading, writing, and applying
diffs. However, while Aider uses predefined tools
and enforces up to three rounds of linting and syn-
tax checks, Codex operates more spontaneously.
Its agents have the freedom to choose tools with
relatively little formalized logic, which introduces
greater uncertainty and increases the likelihood of
errors during the editing process.
F.3 Aider: Common Failure Modes.
Stumble at URL Prototypes.Even though web-
scraping and crawling are terminated, the agent
might sometimes still get tricked with multiple
URL endpoints, that is, a URL prototype or ex-
ample demonstrated in the comment or examples.
CHK-660d8fe425c0f793a16c8d98
inated, the agent
might sometimes still get tricked with multiple
URL endpoints, that is, a URL prototype or ex-
ample demonstrated in the comment or examples.
https://api.myservice.com
Scraping https://api.myservice.com...
Error navigating to https://api.myservice.com:
Page.goto: net::ERR_NAME_NOT_RESOLVED
Call log:
- navigating to "...", waiting until
"networkidle"
Failed to retrieve content from
https://api.myservice.com
https://api.myservice.com/v1/data?user=123
Scraping
https://api.myservice.com/v1/data?user=123...
Error navigating to ...: Page.goto:
net::ERR_NAME_NOT_RESOLVED
Call log:
- navigating to "...", waiting until
"networkidle"
Failed to retrieve content from ...
LLMs do not conform to the code modification
format.
[31m The LLM did not conform to the edit
format.[0m
'fragment': parsed.fragment}
The SEARCH section must exactly match an existing
block of lines
including all white space, comments, indentation,
docstrings, etc
[91mOnly 3 reflections allowed, stopping.[0m
Hallucinate and import non-existing packages.
Some LLMs are prone to hallucinating imports that
cause errors.
45244