Table of Contents
Fetching ...

TOM-SWE: User Mental Modeling For Software Engineering Agents

Xuhui Zhou, Valerie Chen, Zora Zhiruo Wang, Graham Neubig, Maarten Sap, Xingyao Wang

TL;DR

The paper tackles the problem of misalignment between software engineering agents and human developers due to missing explicit models of user intent across long, multi-turn sessions. It introduces ToM-SWE, a dual-agent architecture in which a dedicated theory-of-mind (ToM) agent builds persistent, hierarchical models of users to guide a primary SWE agent, thereby improving task success and user satisfaction. The authors validate the approach on two benchmarks, Ambiguous SWE-bench and Stateful SWE-bench, showing substantial gains in task resolution (e.g., 63.4% vs 51.9% on Ambiguous SWE-bench; 57.4% vs 13.5% on Stateful SWE-bench) and higher user satisfaction, and they corroborate these results with a three-week in-the-wild study involving professional developers, achieving an 86% usefulness rating. They also provide a cost-analysis indicating the ToM component adds modest overhead and offers practical benefits, supporting broader adoption. Overall, ToM-SWE demonstrates that explicit, persistent user modeling enables more efficient, preference-aligned software development with coding agents.

Abstract

Recent advances in coding agents have made them capable of planning, editing, running, and testing complex code bases. Despite their growing ability in coding tasks, these systems still struggle to infer and track user intent, especially when instructions are underspecified or context-dependent. To bridge this gap, we introduce ToM-SWE, a dual-agent architecture that pairs a primary software-engineering (SWE) agent with a lightweight theory-of-mind (ToM) partner agent dedicated to modeling the user's mental state. The ToM agent infers user goals, constraints, and preferences from instructions and interaction history, maintains a \textbf{persistent memory} of the user, and provides user-related suggestions to the SWE agent. In two software engineering benchmarks (ambiguous SWE-bench and stateful SWE-bench), ToM-SWE improves task success rates and user satisfaction. Notably, on the stateful SWE benchmark, a newly introduced evaluation that provides agents with a user simulator along with previous interaction histories, ToM-SWE achieves a substantially higher task success rate of 59.7\% compared to 18.1\% for OpenHands, a state-of-the-art SWE agent. Furthermore, in a three-week study with professional developers using ToM-SWE in their daily work, participants found it useful 86\% of the time, underscoring the value of stateful user modeling for practical coding agents.

TOM-SWE: User Mental Modeling For Software Engineering Agents

TL;DR

The paper tackles the problem of misalignment between software engineering agents and human developers due to missing explicit models of user intent across long, multi-turn sessions. It introduces ToM-SWE, a dual-agent architecture in which a dedicated theory-of-mind (ToM) agent builds persistent, hierarchical models of users to guide a primary SWE agent, thereby improving task success and user satisfaction. The authors validate the approach on two benchmarks, Ambiguous SWE-bench and Stateful SWE-bench, showing substantial gains in task resolution (e.g., 63.4% vs 51.9% on Ambiguous SWE-bench; 57.4% vs 13.5% on Stateful SWE-bench) and higher user satisfaction, and they corroborate these results with a three-week in-the-wild study involving professional developers, achieving an 86% usefulness rating. They also provide a cost-analysis indicating the ToM component adds modest overhead and offers practical benefits, supporting broader adoption. Overall, ToM-SWE demonstrates that explicit, persistent user modeling enables more efficient, preference-aligned software development with coding agents.

Abstract

Recent advances in coding agents have made them capable of planning, editing, running, and testing complex code bases. Despite their growing ability in coding tasks, these systems still struggle to infer and track user intent, especially when instructions are underspecified or context-dependent. To bridge this gap, we introduce ToM-SWE, a dual-agent architecture that pairs a primary software-engineering (SWE) agent with a lightweight theory-of-mind (ToM) partner agent dedicated to modeling the user's mental state. The ToM agent infers user goals, constraints, and preferences from instructions and interaction history, maintains a \textbf{persistent memory} of the user, and provides user-related suggestions to the SWE agent. In two software engineering benchmarks (ambiguous SWE-bench and stateful SWE-bench), ToM-SWE improves task success rates and user satisfaction. Notably, on the stateful SWE benchmark, a newly introduced evaluation that provides agents with a user simulator along with previous interaction histories, ToM-SWE achieves a substantially higher task success rate of 59.7\% compared to 18.1\% for OpenHands, a state-of-the-art SWE agent. Furthermore, in a three-week study with professional developers using ToM-SWE in their daily work, participants found it useful 86\% of the time, underscoring the value of stateful user modeling for practical coding agents.
Paper Structure (57 sections, 7 figures, 3 tables, 1 algorithm)

This paper contains 57 sections, 7 figures, 3 tables, 1 algorithm.

Figures (7)

  • Figure 1: An example of how the ToM-SWE framework can help the SWE agent to model the user's mental state and provide more useful suggestions based on the previous interaction history. When facing a casual starting instruction, the SWE agent simply generates code yet fails to meet the users' requirement for the task. However, with the ToM agent, the SWE agent can first consult the ToM agent that persists user mental state across multiple sessions, and then act more aligned with the user's preferences and constraints.
  • Figure 2: Overview of the ToM-SWE framework: the SWE agent handles code generation and execution, while the ToM agent focuses on user modeling and intent inference. The SWE agent consults the ToM agent to predict the user's mental state before suggesting technical actions. Meanwhile, the ToM agent maintains an external hierarchical memory system to persist the user's state and update user models after each session (with update_memory action).
  • Figure 3: Overview of the stateful SWE benchmark. We first collect profiles following the three steps outlined above. We then create instances by pairing the user simulator of different profiles with SWE-bench issues. Original SWE-bench issue descriptions are rephrased by the user simulator into casual, natural-sounding starting instructions. The agent solves the task under the same environment and tests of the original instance with access to the previous interaction histories with the user and could interact with the simulated user for extra information.
  • Figure 4: Agent performance comparison across models. TomCodeAct agent consistently outperforms CodeAct agent across both benchmarks and model variants, with the largest performance gap observed in the Stateful SWE benchmark using Claude Sonnet 4.
  • Figure 5: Task resolution and user satisfaction disagreement. F+H: the proportion of cases where the user simulator statisfaction score is high given the task is not resolved. S+M: the proportion of cases where the user simulator statisfaction score is medium or low given the task is resolved.
  • ...and 2 more figures