Theory of Mind modeling for Software Engineering assistants
Project description
TOM-SWE: User Mental Modeling For Software Engineering Agents
News
- [10/2025] Beta testing program launched - join us in testing ToM-enhanced agents!
Introduction
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.
Join the Beta Test
pip install uv
uvx --python 3.12 --from git+https://github.com/XuhuiZhou/OpenHands@feature/tom-codeact-agent openhands
For details, please refer to the Google doc
Get Started
Install from PyPI
pip install tom-swe
PyPI page: https://pypi.org/project/tom-swe/
Install Locally
We recommend using a virtual environment with uv:
pip install uv
uv sync
[!NOTE] 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.
Set up LLM API Credentials
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-20250514
Easy Sample Demo
You 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
Core Features
- 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
Main Commands
# 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-agent
OpenHands Integration
Configure 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
Prompts
The prompts are stored in tom_swe/prompts/registry.py. You can also find some prompts in tom_swe/generation/dataclass.py
Requirements
- Python 3.8+
- uv package manager
- LLM API key (contact All Hands AI for access)
Citation
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}
}
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tom_swe-1.0.1.tar.gz.
File metadata
- Download URL: tom_swe-1.0.1.tar.gz
- Upload date:
- Size: 41.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
862b64ac642ca1517a97882111483f375fcfdc6e8b99f2a1b9bd24323b15adc8
|
|
| MD5 |
a4d58f250022a5b2adb821145bbd227e
|
|
| BLAKE2b-256 |
de2bf9662e31c728264efec9361e95a38fe4c2e70359bbad3442bc18fd34ce2e
|
Provenance
The following attestation bundles were made for tom_swe-1.0.1.tar.gz:
Publisher:
publish-to-pypi.yml on OpenHands/ToM-SWE
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tom_swe-1.0.1.tar.gz -
Subject digest:
862b64ac642ca1517a97882111483f375fcfdc6e8b99f2a1b9bd24323b15adc8 - Sigstore transparency entry: 695123339
- Sigstore integration time:
-
Permalink:
OpenHands/ToM-SWE@e807599d5cd93ace0111545763c63f55c6a6af83 -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/OpenHands
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@e807599d5cd93ace0111545763c63f55c6a6af83 -
Trigger Event:
release
-
Statement type:
File details
Details for the file tom_swe-1.0.1-py3-none-any.whl.
File metadata
- Download URL: tom_swe-1.0.1-py3-none-any.whl
- Upload date:
- Size: 51.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3b74e94712f84c0d27a1dff50fa831efb383cbd370a25b0687870867ea5864a1
|
|
| MD5 |
ae238f85d5e1d4f45dd54f10e9a11ca2
|
|
| BLAKE2b-256 |
20a7a68ad9216fa36e596ea6b624bd80dafc03bffb22e4e954ecf3e36c26fa47
|
Provenance
The following attestation bundles were made for tom_swe-1.0.1-py3-none-any.whl:
Publisher:
publish-to-pypi.yml on OpenHands/ToM-SWE
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tom_swe-1.0.1-py3-none-any.whl -
Subject digest:
3b74e94712f84c0d27a1dff50fa831efb383cbd370a25b0687870867ea5864a1 - Sigstore transparency entry: 695123343
- Sigstore integration time:
-
Permalink:
OpenHands/ToM-SWE@e807599d5cd93ace0111545763c63f55c6a6af83 -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/OpenHands
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@e807599d5cd93ace0111545763c63f55c6a6af83 -
Trigger Event:
release
-
Statement type: