TL;DR
The paper introduces SWE-MISBEHAVIOR, the first benchmark designed to detect "boundary violations" in autonomous coding agents—actions where an agent oversteps its task, such as silently corrupting unrelated files or breaking system integrity. To fix this, the authors propose CODE-KIT, an adaptive tool-scaffolding framework that reduces these dangerous misbehaviors by up to 52% while actually improving overall task performance.
What Problem Does This Paper Address?
As LLM-based coding agents (like OpenHands or Claude Code) move from simple code completion to autonomous repository-level engineering, they gain the power to edit files and execute shell commands. However, this autonomy comes with a "blind spot": existing benchmarks like SWE-bench only measure task success (e.g., "did the bug get fixed?").
They ignore the operational cost and collateral damage. An agent might fix a bug but unknowingly delete a production database, install insecure packages, or modify files it wasn't supposed to touch. The authors term these "boundary violations." Without a way to measure these silent failures, we cannot safely deploy autonomous agents in real-world production environments.
Methods
The authors tackle this by first defining a taxonomy of 11 misbehaviors across three categories: Code Generation, File Management, and System Interaction. They then developed an automated evaluation protocol that uses a mix of language-specific static analysis (Abstract Syntax Trees) and high-quality LLM-judges to detect violations like syntax errors, unintended context changes, and resource exhaustion.
To mitigate these issues, they introduced CODE-KIT, a lightweight adaptive framework. Instead of just giving an agent a massive list of "don'ts" in a prompt, CODE-KIT uses a dedicated "selector" model to provide the agent with only the minimal, task-specific subset of tools and guidelines needed. For example, if an agent only needs to edit one function, CODE-KIT gives it a specialized write_function_implementation tool that physically prevents it from overwriting the rest of the file.
Datasets
The authors introduced the SWE-MISBEHAVIOR benchmark, which consists of:
- 7.4K human-in-the-loop synthesized samples drawn from 115 real-world GitHub repositories.
- 1,384 scripts with human-curated prompts.
- The dataset is structured across three layers of an agent's action space, as shown in the analysis below:
Key Insights and Ideas
- Action-Control Failure vs. Knowledge Failure: The authors found that misbehaviors aren't usually caused by the agent "not knowing" how to code. Instead, they are failures of tool usage. Agents often have "overly broad" tools (like a general file editor) that make it too easy to make mistakes.
- "Shoot First, Ask Questions Later": A major finding was that agents frequently act without reading necessary dependencies. In system interaction tasks, agents failed to read required files in up to 98.5% of cases.
- Prompting is Not Enough: Simply adding "be careful" to a prompt (Permission Rules) often yielded inconsistent results or even worsened performance. True safety requires constrained affordances—tools that are physically limited in what they can do.
- Framework "Personalities": Different agent frameworks (like OpenHands vs. Agno) exhibit distinct misbehavior profiles. For instance, OpenHands often violates environment integrity because its native interface bundles read and write access together.
Key Results
The study revealed that state-of-the-art agents are surprisingly "messy":
- OpenHands and smolagents inadvertently modified user inputs in 50.5% of cases and silently compromised environment integrity in 53% of cases.
- CODE-KIT proved highly effective, reducing average misbehavior rates by 52% for smolagents and 32% for OpenHands.
- Crucially, CODE-KIT improved task completion while reducing errors. By narrowing the agent's focus to relevant tools, it reduced "choice overload," leading to more precise and successful actions.
Limitations and Future Work
While SWE-MISBEHAVIOR is a major step forward, the authors acknowledge several limitations:
- Benign vs. Malicious: The benchmark focuses on "benign" misbehavior (accidental mistakes) rather than intentional security threats like data exfiltration or malicious code injection.
- Horizon Limits: CODE-KIT currently operates on a per-step basis. Future work is needed to scale these "action-space scaffolds" to longer-horizon, multi-step tasks like full feature prototyping.
- Deep Dependencies: Even with specialized tools, agents still struggle to trace very deep, indirect dependency chains across a large codebase.
Summary updated