TOM-SWE: User Mental Modeling For Software Engineering Agents

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

Introduction

Current software engineering (SWE) agents are technically impressive—capable of planning, editing, and testing complex codebases. However, they are often socially "stateless." They treat every interaction as a blank slate, ignoring a developer's specific coding style, preferred libraries, or previous feedback. When a user provides an underspecified instruction like "implement a web scraper," a standard agent might choose a library the user dislikes or ignore established project conventions.

This lack of "Theory of Mind"—the ability to infer and track a collaborator's mental state—leads to wasted effort, user frustration, and a constant need for repetitive clarification. To bridge this gap, researchers introduce ToM-SWE, a dual-agent architecture that pairs a primary coding agent with a "Theory of Mind" (ToM) partner agent. By separating technical execution from user modeling, this system achieves a massive performance leap, improving task success rates from 18.1% to 59.7% on stateful benchmarks and gaining an 86% acceptance rate from professional developers in real-world use.

The Dual-Agent Architecture

ToM-SWE splits the workload to prevent a single agent from becoming overwhelmed by managing both complex code and complex user context.

  1. The SWE Agent: A primary agent focused exclusively on technical tasks, such as writing code, running tests, and executing terminal commands.
  2. The ToM Agent: A lightweight partner dedicated to modeling the user. It observes interactions and maintains a three-tier hierarchical memory:
  3. Tier 1 (Raw Sessions): A complete history of past interactions.
  4. Tier 2 (Session-based User Model): An analysis of specific sessions, capturing immediate intent, emotions, and preferences.
  5. Tier 3 (Overall User Model): A high-level summary of the user’s global preferences, interaction style, and coding standards.

During an active session, the SWE agent can consult the ToM agent to clarify ambiguous instructions. After a session ends, the ToM agent performs "sleep-time" processing to update the global user profile, ensuring the system continuously learns and adapts to the user over time.

Evaluation and Datasets

The researchers evaluated ToM-SWE across three distinct environments:

  • Ambiguous SWE-bench: A stateless benchmark where instructions are intentionally underspecified to test ambiguity handling.
  • Stateful SWE-bench (New): A newly introduced benchmark providing agents with realistic conversation histories and 15 distinct "developer profiles" (e.g., developers preferring concise responses versus detailed explanations). It uses an LLM-powered user simulator to evaluate multi-turn adaptation.
  • In-the-wild Human Study: A three-week field study involving 17 professional developers using the system in their daily workflows.

Key Results and Insights

The separation of concerns proved highly effective. A single agent trying to handle both coding and user modeling often gets distracted by context; separating these roles preserves technical performance while allowing the ToM agent to specialize in social inference.

  • Benchmark Dominance: On the Stateful SWE-bench, ToM-SWE (powered by Claude 4) achieved a 59.7% success rate, dwarfing the 18.1% achieved by the state-of-the-art OpenHands CodeAct agent.
  • Ambiguity Handling: On the Ambiguous SWE-bench, the architecture improved the issue resolution rate from 51.9% to 63.4%.
  • Human Validation: In the three-week field study, developers accepted or partially accepted the ToM agent’s proactive suggestions 86% of the time.
  • Cost Efficiency: Adding the ToM agent is relatively inexpensive. Using a high-end model for the ToM agent adds only about 16% overhead to the total session cost while providing a massive boost in utility.

Qualitative Takeaways

  • Abstraction over Retrieval: Simply using Retrieval-Augmented Generation (RAG) to pull up old chat logs is insufficient. The ToM agent succeeds because it abstracts those logs into concrete constraints (e.g., "User prefers httpx over requests").
  • The "Good-Effort Bonus": User satisfaction isn't solely tied to bug resolution. When the agent failed to resolve a task but still followed the user's preferred workflow and communicated clearly, user satisfaction remained high. Process quality matters as much as the final output.
  • Confidence Matters: ToM suggestions were most successful when the agent had high confidence (90-95%). When the agent was uncertain but made a suggestion anyway, it often felt generic and was rejected by users.

Limitations and Future Work

While ToM-SWE represents a significant step forward for collaborative AI, several challenges remain:

  • Profile Diversity: The 15 developer profiles used in the new benchmark were predominantly based on English-speaking developers, which may not capture the full global diversity of coding practices.
  • Privacy: Modeling user behavior inherently requires storing personal data. While on-device storage or user-controlled memory are proposed mitigations, balancing privacy with utility remains an ongoing challenge.
  • Extreme Ambiguity: The ToM agent still struggles when queries are entirely devoid of technical context.
  • Generalization: While highly successful in software engineering, future research will need to explore how well this dual-agent "Theory of Mind" framework translates to other collaborative domains, such as creative writing or data analysis.

Summary updated

BibTeX
@inproceedings{zhou2026tom,
  author = {Xuhui Zhou and Valerie Chen and Zora Zhiruo Wang and Graham Neubig and Maarten Sap and Xingyao Wang},
  title = {{TOM-SWE: User Mental Modeling For Software Engineering Agents}},
  booktitle = {International Conference on Machine Learning},
  year = {2026},
  url = {https://openreview.net/forum?id=HeLa76rJuD},
}
Figure