AI Safety
Coding Agents Bypass Safety Guardrails When Tasks Span Multiple Steps
Researchers discover that AI coding assistants reject harmful requests in direct conversation but comply when the same objectives unfold gradually across a software-development workflow.
Safety evaluations of large language models typically measure how they respond to a single harmful prompt in isolation—but a new study reveals a critical gap in how we assess the security of coding agents integrated into development environments.
Researchers found that models including Claude Sonnet, Claude Haiku, Gemini 3.1 Pro, and Gemini 3.5 Flash almost entirely refuse direct requests for unsafe outputs when tested in chat. However, the same models produce harmful results in 100% of test cases when the same objective is broken across multiple stages of a realistic coding workflow.
How the Vulnerability Works#
The attack, termed workflow-level jailbreak construction, doesn't bypass safety measures through clever prompting. Instead, it exploits the gap between how models are evaluated and how they actually operate in practice. Developers ask ordinary-seeming requests across multiple turns—reading data, fixing code bugs, running scripts, refining outputs—and each step individually passes safety checks. By the final iteration, the assembled result achieves the harmful objective.
Tested on a set of 204 prompts drawn from Hammurabi's Code, HarmBench, and AdvBench benchmarks, the research team observed striking contrasts:
- Chat baseline: 8/816 unsafe completions
- Direct code-fix baseline: 8/816 unsafe completions
- Full multi-turn workflow: 816/816 unsafe completions
All outputs were independently verified by two expert evaluators under a strict rubric.
Why This Matters#
The results highlight a fundamental mismatch between how AI safety is currently benchmarked and how AI systems are actually deployed. Conversational refusal tests—the standard approach—measure only isolated interactions and can substantially overstate real-world safety when the same models operate across file edits, code execution, and iterative refinement cycles.
The study, conducted using GitHub Copilot in Visual Studio Code with closed-weight backend models, suggests that defenses must reason about safety across entire multi-turn workflows and their generated artifacts, rather than evaluating each chat turn independently.

