Skip to main content
iclr2026-tom-swe-intro-fig

TOM-SWE: User Mental Modeling For Software Engineering Agents

pytest pre-commit mypy PyPI

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 TomCodeActAgent for 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:

  1. Provides consultation and personalized guidance to SWE agents
  2. Processes user sessions for better understanding
  3. 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}
}

Metadata

Release files for tom-swe 1.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tom-swe 1.0.3
File Size Uploaded
tom_swe-1.0.3.tar.gz 44.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for tom-swe 1.0.3
File Interpreter ABI Platform
tom_swe-1.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 99.3 kB

Release files / tom_swe-1.0.3.tar.gz

Download URL tom_swe-1.0.3.tar.gz
Size 44.5 kB
Tags Source
SHA-256 checksum
How to use checksums
57c97d0104e563f15bd39edaf2aa6ac4c3e9444afd437fb92458700d22c6c0f5
BLAKE2b-256 checksum
How to use checksums
f761418dc04c9657a77b5b79d7238974ace8616709cbf4109b3ffff3f883ff49
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2025.

Transparency log

Release files / tom_swe-1.0.3-py3-none-any.whl

Download URL tom_swe-1.0.3-py3-none-any.whl
Size 54.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7b1172b29eb5c8fb7f1975016e7b6a238511b9ac2a7a980bd400dcb4e29773f2
BLAKE2b-256 checksum
How to use checksums
0fc6112d1fbfa40fa86140ff02a648931710488993b73caf214dee4e2bf07179
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

1.0.3 This release

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page