Why OpenHands SDK?
๐ฏ Correctness & Reliability
- Event-sourced architecture for perfect reproducibility
- Immutable state eliminates entire classes of bugs
- Type-safe APIs catch errors at compile time
- Time-travel debugging via event replay
๐ ๏ธ Developer Experience
- Stateless agents are easy to test and compose
- 100+ LLM providers via LiteLLM integration
- Native MCP support for thousands of tools
- Clear, minimal API with sensible defaults
๐ Production Ready
- Built-in REST/WebSocket server with authentication
- Container sandboxing for secure execution
- Auto context condensation (60-70% token reduction)
- Interactive debugging via VNC, VSCode Web
๐ Research Friendly
- Custom agents for arbitrary reasoning strategies
- LLM routing for A/B testing
- Event logs for retrospective analysis
- Microagents for rapid prompt engineering
Use Cases
The SDK enables a wide range of applications:- Documentation Automation - Agents that analyze code changes and update documentation
- SRE Assistants - Debug production issues by analyzing logs and code together
- Data Processing - Transform unstructured data into structured database entries
- Code Review Bots - Automatically review PRs and suggest improvements
- Testing Automation - Generate and maintain test suites
- DevOps Agents - Automate deployment and infrastructure management
Hello World Example
This is what it looks like to write a program with an OpenHands agent:Installation & Quickstart
Prerequisites
- Python 3.12+
uvpackage manager (version 0.8.13+)
Acquire and Set an LLM API Key
Obtain an API key from your favorite LLM provider, any provider supported by LiteLLM is supported by the Agent SDK, although we have a set of recommended models that work well with OpenHands agents. If you want to get started quickly, you can sign up for the OpenHands Cloud and go to the API key page, which allows you to use most of our recommended models with no markup โ documentation is here. Once you do this, you canexport LLM_API_KEY=xxx to use all the examples.
Setup
Once this is done, run the following to do a Hello World example.Documentation Structure
๐ Architecture & Core Concepts
Architecture Overview - High-level system design with Mermaid diagrams- Event-sourced state management
- Stateless agent design
- Component interaction patterns
- Design principles and benefits
- ConversationState - Event-sourced state management
- Agent - Stateless decision logic
- LLM - Model abstraction and routing
- Tools - Action execution framework
- Conversation - Orchestration API
๐ Advanced Features
Advanced Features Overview - Production capabilities- Context Condensation - Reduce token usage by 60-70%
- Context Files & Microagents - Inject targeted knowledge
- Task Tracking - Built-in TODO lists
- Stuck Detection - Detect infinite loops
๐ Security & Production
Security - Defense in depth- Security Analyzer - Two-tier risk analysis
- Confirmation Policies - Custom approval workflows
- Secrets Management - Auto-masking sensitive data
- Production Server - Built-in REST/WebSocket APIs
- Container Sandboxing - Isolated execution
- Interactive Workspace - VNC, VSCode Web, SSH
๐ Guides & Examples
Examples - Complete working examples01_hello_world.py- Basic agent usage09_pause_example.py- Pause and resume14_context_condenser.py- Context management- And 20+ more examples covering all features
Quick Start Paths
For Researchers
- Start with Hello World
- Read Architecture Overview
- Explore Custom Agents
- Check Advanced Features
For Production Engineers
- Start with Hello World
- Review Security
- Set up Production Server
- Configure Container Sandboxing
For Integration Developers
- Start with Hello World
- Understand Event System
- Explore Tools
- Check MCP Integration
Key Concepts
Event Sourcing
All state is derived from an immutable event log, enabling:- Perfect reproducibility
- Time-travel debugging
- Complete audit trails
- Zero race conditions
Stateless Agents
Agents are pure functions with no internal state:- Easy to test (no mocking)
- Easy to serialize (send over network)
- Easy to scale (run anywhere)
- Easy to compose (sub-agents)
Immutable Configuration
All configuration is frozen after creation:- No config drift
- Type-safe at compile time
- Easy to version control
- Clear dependencies
Next Steps
- Architecture Overview - Understand the system design
- Core Components - Learn the building blocks
- Advanced Features - Explore production capabilities
- Examples - See working code
Community & Support
- GitHub: All-Hands-AI/agent-sdk
- Issues: Report bugs or request features
- Discord: Join the community
- Docs: Full documentation

