- [10/2025] Beta testing program launched - join us in testing ToM-enhanced agents!
ToM-SWE is a Theory of Mind package designed to enhance Software Engineering agents with personalized user understanding and adaptive behavior.
ToM-SWE integrates seamlessly with OpenHands and other SWE agent frameworks, providing consultation capabilities that help agents understand user intent, preferences, and working styles for improved task performance.
pip install uv
uvx --python 3.12 --from git+https://github.com/XuhuiZhou/OpenHands@feature/tom-codeact-agent openhandsFor details, please refer to the Google doc
pip install tom-swePyPI page: https://pypi.org/project/tom-swe/
We recommend using a virtual environment with uv:
pip install uv
uv syncNote
You can use any other package manager to install dependencies (e.g. pip, conda), but we strongly recommend using uv for the best development experience.
Create a .env file with your credentials:
LITELLM_API_KEY=your_api_key_here
LITELLM_BASE_URL=your_proxy_endpoint
DEFAULT_LLM_MODEL=litellm_proxy/claude-sonnet-4-20250514You can test the consultation functionality with a simple example:
from tom_swe.tom_module import TomModule
import asyncio
async def demo():
tom = TomModule()
# Consult on user preferences
consultation = await tom.consult(
user_id="demo_user",
current_context="User wants to implement a new feature"
)
print(consultation)
asyncio.run(demo())Or run the included example:
uv run python example.py # See consultation functionality in action
uv run tom-config # Interactive LLM setup- Three-Tier Memory: Cleaned sessions → Session analyses → User profiles
- Agent Consultation: Provides personalized guidance and recommendations for SWE agents
- User Behavior Analysis: LLM-powered psychological insights and preferences
- OpenHands Integration: Use
TomCodeActAgentfor automatic instruction enhancement
# User analysis
uv run user-analysis --user-id <user_id>
uv run user-analysis --all-users --sample-size 100
# Theory of Mind analysis
uv run tom-test # Test on sample users
uv run tom-analyze # Full analysis
# RAG document analysis
uv run rag-agentConfigure OpenHands to use Tom-enhanced agent:
default_agent = "TomCodeActAgent"The agent automatically:
- Provides consultation and personalized guidance to SWE agents
- Processes user sessions for better understanding
- Shows progress during analysis
The prompts are stored in tom_swe/prompts/registry.py. You can also find some prompts in tom_swe/generation/dataclass.py
- Python 3.8+
- uv package manager
- LLM API key (contact All Hands AI for access)
If you use ToM-SWE in your research, please cite:
@software{zhou2024tomswe,
title = {TOM-SWE: User Mental Modeling For Software Engineering Agents},
author = {Xuhui Zhou and Valerie Chen and Zora Zhiruo Wang and
Graham Neubig and Maarten Sap and Xingyao Wang},
year = {2025},
url = {https://github.com/All-Hands-AI/TOM-SWE}
}