Skip to main content

Overview

Tom (Theory of Mind) Agent provides advanced user understanding capabilities that help your agent interpret vague instructions and adapt to user preferences over time. Built on research in user mental modeling, Tom agents can:
  • Understand unclear or ambiguous user requests
  • Provide personalized guidance based on user modeling
  • Build long-term user preference profiles
  • Adapt responses based on conversation history
This is particularly useful when:
  • User instructions are vague or incomplete
  • You need to infer user intent from minimal context
  • Building personalized experiences across multiple conversations
  • Understanding user preferences and working patterns

Research Foundation

Tom agent is based on the TOM-SWE research paper on user mental modeling for software engineering agents:
Citation

Quick Start

This example is available on GitHub: examples/01_standalone_sdk/30_tom_agent.py
examples/01_standalone_sdk/30_tom_agent.py
You can run the example code as-is.
The model name should follow the LiteLLM convention: provider/model_name (e.g., anthropic/claude-sonnet-4-5-20250929, openai/gpt-4o). The LLM_API_KEY should be the API key for your chosen provider.
ChatGPT Plus/Pro subscribers: You can use LLM.subscription_login() to authenticate with your ChatGPT account and access Codex models without consuming API credits. See the LLM Subscriptions guide for details.

Tom Tools

TomConsultTool

The consultation tool provides personalized guidance when the agent encounters vague or unclear user requests:
Key features:
  • Analyzes conversation history for context
  • Provides personalized suggestions based on user modeling
  • Helps disambiguate vague instructions
  • Adapts to user communication patterns

SleeptimeComputeTool

The indexing tool processes conversation history to build user preference profiles:
Key features:
  • Processes conversation history into user models
  • Stores preferences in ~/.openhands/ directory
  • Builds understanding of user patterns over time
  • Enables long-term personalization across sessions

Configuration

RAG Support

Enable retrieval-augmented generation for enhanced context awareness:

Custom LLM for Tom

You can optionally use a different LLM for Tom’s internal reasoning:

Data Storage

Tom stores user modeling data persistently in ~/.openhands/:
~/.openhands
user_models
{user_id}
user_model.json
processed_sessions_timestamps.json
conversations
{session_id}
events
where
  • user_models/ stores user preference profiles, with each user having their own subdirectory containing user_model.json (the current user model).
  • conversations/ contains indexed conversation data
This persistent storage enables Tom to:
  • Remember user preferences across sessions
  • Track which conversations have been indexed
  • Build long-term understanding of user patterns

Use Cases

1. Handling Vague Requests

When a user provides minimal information:

2. Personalized Recommendations

Tom adapts suggestions based on past interactions:

3. Intent Inference

Understanding what the user really wants:

Best Practices

  1. Enable RAG: For better context awareness, always enable RAG:
  2. Index Regularly: Run sleeptime compute after important conversations to build better user models
  3. Provide Context: Even with Tom, providing more context leads to better results
  4. Monitor Data: Check ~/.openhands/ periodically to understand what’s being learned
  5. Privacy Considerations: Be aware that conversation data is stored locally for user modeling

Next Steps