Skip to content

Commit dfa8f56

Browse files
committed
initial version of ovewviews
1 parent 43387ed commit dfa8f56

1 file changed

Lines changed: 116 additions & 105 deletions

File tree

‎sdk/arch/overview.mdx‎

Lines changed: 116 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -1,142 +1,153 @@
11
---
22
title: Overview
3-
description: A modular framework for building AI agents, organized into four packages for clarity and extensibility.
3+
description: Understanding the OpenHands Agent SDK's design philosophy, package structure, and core principles.
44
---
55

6-
The OpenHands Agent SDK is organized into four packages, each serving a distinct purpose in the agent development lifecycle.
6+
The **OpenHands Agent SDK** provides a unified, type-safe framework for building and deploying AI agents—from local experiments to full production systems, focused on **statelessness**, **composability**, and **clear boundaries** between research and deployment.
77

8-
## Package Structure
98

10-
```mermaid
11-
graph TD
12-
SDK[SDK Package<br/>Core Framework] --> Tools[Tools Package<br/>Built-in Tools]
13-
SDK --> Workspace[Workspace Package<br/>Execution Environments]
14-
SDK --> AgentServer[Agent Server Package<br/>Remote Execution]
15-
16-
Tools -.->|Used by| SDK
17-
Workspace -.->|Used by| SDK
18-
AgentServer -.->|Hosts| SDK
19-
20-
style SDK fill:#e1f5fe
21-
style Tools fill:#e8f5e8
22-
style Workspace fill:#fff3e0
23-
style AgentServer fill:#f3e5f5
24-
```
9+
<Info>
10+
**Context:** The **OpenHands Agent SDK** is part of the [OpenHands V1](https://openhands.dev/blog/the-path-to-openhands-v1) effort — a complete architectural rework based on lessons from **OpenHands V0**, one of the most widely adopted open-source coding agents.
11+
[Over the last eighteen months](https://openhands.dev/blog/one-year-of-openhands-a-journey-of-open-source-ai-development), OpenHands V0 evolved from a scrappy prototype into a widely used open-source coding agent. The project grew to tens of thousands of GitHub stars, hundreds of contributors, and multiple production deployments. That growth exposed architectural tensions — tight coupling between research and production, mandatory sandboxing, mutable state, and configuration sprawl — which informed the design principles of agent-sdk in V1.
12+
</Info>
2513

26-
## 1. SDK Package
14+
## Design Principles
2715

28-
Core framework for building agents locally.
16+
### Optional Isolation over Mandatory Sandboxing
2917

30-
**Key Components:**
31-
- **[Tool System](/sdk/architecture/sdk/tool)** - Define custom capabilities
32-
- **[Microagents](/sdk/architecture/sdk/microagents)** - Specialized behavior modules
33-
- **[Condenser](/sdk/architecture/sdk/condenser)** - Memory management
34-
- **[Agent](/sdk/architecture/sdk/agent)** - Base agent interface
35-
- **[Workspace](/sdk/architecture/sdk/workspace)** - Execution abstraction
36-
- **[Conversation](/sdk/architecture/sdk/conversation)** - Lifecycle management
37-
- **[Event](/sdk/architecture/sdk/event)** - Event system
38-
- **[LLM](/sdk/architecture/sdk/llm)** - Language model integration
39-
- **[MCP](/sdk/architecture/sdk/mcp)** - Model Context Protocol
40-
- **[Security](/sdk/architecture/sdk/security)** - Security framework
18+
<Info>
19+
**V0 Challenge:**
20+
Every tool call in V0 executed in a sandboxed Docker container by default. While this guaranteed reproducibility and security, it also created friction — the agent and sandbox ran as separate processes, states diverged easily, and multi-tenant workloads could crash each other.
21+
Moreover, with the rise of the Model Context Protocol (MCP), which assumes local execution and direct access to user environments, V0’s rigid isolation model became incompatible.
22+
</Info>
4123

42-
## 2. Tools Package
24+
**V1 Principle:**
25+
**Sandboxing should be opt-in, not universal.**
26+
V1 unifies agent and tool execution within a single process by default, aligning with MCP’s local-execution model.
27+
When isolation is needed, the same stack can be transparently containerized, maintaining flexibility without complexity.
4328

44-
Production-ready tool implementations.
29+
### Stateless by Default, One Source of Truth for State
4530

46-
**Available Tools:**
47-
- **[BashTool](/sdk/architecture/tools/bash)** - Command execution
48-
- **[FileEditorTool](/sdk/architecture/tools/file_editor)** - File manipulation
49-
- **[GlobTool](/sdk/architecture/tools/glob)** - File discovery
50-
- **[GrepTool](/sdk/architecture/tools/grep)** - Content search
51-
- **[TaskTrackerTool](/sdk/architecture/tools/task_tracker)** - Task management
52-
- **[PlanningFileEditorTool](/sdk/architecture/tools/planning_file_editor)** - Multi-file workflows
53-
- **[BrowserUseTool](/sdk/architecture/tools/browser_use)** - Web interaction
31+
<Info>
32+
**V0 Challenge:**
33+
V0 relied on mutable Python objects and dynamic typing, which led to silent inconsistencies — failed session restores, version drift, and non-deterministic behavior. Each subsystem tracked its own transient state, making debugging and recovery painful.
34+
</Info>
5435

55-
## 3. Workspace Package
36+
**V1 Principle:**
37+
**Keep everything stateless, with exactly one mutable state.**
38+
All components (agents, tools, LLMs, and configurations) are immutable Pydantic models validated at construction.
39+
The only mutable entity is the [conversation state](https://github.com/All-Hands-AI/agent-sdk/blob/main/openhands-sdk/openhands/sdk/event/conversation_state.py), a single source of truth that enables deterministic replay and robust persistence across sessions or distributed systems.
5640

57-
Advanced execution environments for production.
41+
### Clear Boundaries between Agent and Applications
5842

59-
**Workspace Types:**
60-
- **[DockerWorkspace](/sdk/architecture/workspace/docker)** - Container-based isolation
61-
- **[RemoteAPIWorkspace](/sdk/architecture/workspace/remote_api)** - Remote server execution
43+
<Info>
44+
**V0 Challenge:**
45+
The same codebase powered the CLI, web interface, and integrations (e.g., Github, Gitlab, etc). Over time, application-specific conditionals and prompts polluted the agent core, making it brittle.
46+
Heavy research dependencies and benchmark integrations further bloated production builds.
47+
</Info>
6248

63-
See [Workspace Overview](/sdk/architecture/workspace/overview) for comparison.
49+
**V1 Principle:**
50+
**Maintain strict separation of concerns.**
51+
V1 divides the system into stable, isolated layers: the [SDK (agent core)](/sdk/arch/overview#1-sdk-%E2%80%93-openhands-sdk), [tools (set of tools)](/sdk/arch/overview#2-tools-%E2%80%93-openhands-tools), [workspace (sandbox)](/sdk/arch/overview#3-workspace-%E2%80%93-openhands-workspace), and [agent server (server that runs inside sandbox)](/sdk/arch/overview#4-agent-server-%E2%80%93-openhands-agent-server).
52+
Applications communicate with the agent via APIs rather than embedding it directly, ensuring research and production can evolve independently.
6453

65-
## 4. Agent Server Package
6654

67-
HTTP server for centralized agent execution.
55+
### Composable Components for Extensibility
6856

69-
**Capabilities:**
70-
- Remote agent execution via API
71-
- Multi-user isolation
72-
- Container management
73-
- Resource allocation
57+
<Info>
58+
**V0 Challenge:**
59+
Because agent logic was hard-coded into the core application, extending behavior (e.g., adding new tools or entry points) required branching logic for different entrypoints. This rigidity limited experimentation and discouraged contributions.
60+
</Info>
7461

75-
See [Agent Server Documentation](/sdk/architecture/agent_server/overview).
62+
**V1 Principle:**
63+
**Everything should be composable and safe to extend.**
64+
Agents are defined as graphs of interchangeable components—tools, prompts, LLMs, and contexts—each described declaratively with strong typing.
65+
Developers can reconfigure capabilities (e.g., swap toolsets, override prompts, add delegation logic) without modifying core code, preserving stability while fostering rapid innovation.
7666

77-
## Component Interaction
67+
## Package Overview
7868

7969
```mermaid
80-
graph LR
81-
User[User] -->|Message| Conv[Conversation]
82-
Conv -->|Manages| Agent[Agent]
83-
84-
Agent -->|Reasons with| LLM[LLM]
85-
Agent -->|Executes| Tools[Tools]
86-
Agent -->|Guided by| Micro[Microagents]
87-
88-
Tools -->|Run in| Workspace[Workspace]
89-
90-
style User fill:#e1f5fe
91-
style Conv fill:#fff3e0
92-
style Agent fill:#f3e5f5
93-
style LLM fill:#e8f5e8
94-
style Tools fill:#fce4ec
95-
style Workspace fill:#e0f2f1
70+
graph TD
71+
SDK[SDK<br/>openhands.sdk<br/><i>Core Framework</i>]
72+
Tools[Tools<br/>openhands.tools<br/><i>Built-in Capabilities</i>]
73+
Workspace[Workspace<br/>openhands.workspace<br/><i>Execution Environments</i>]
74+
Server[Agent Server<br/>openhands.agent_server<br/><i>Remote API Layer</i>]
75+
76+
SDK --> Tools
77+
SDK --> Workspace
78+
Server --> SDK
79+
Server --> Workspace
80+
81+
style SDK fill:#e1f5fe
82+
style Tools fill:#e8f5e8
83+
style Workspace fill:#fff3e0
84+
style Server fill:#f3e5f5
9685
```
9786

98-
## Design Principles
9987

100-
### Immutability & Serialization
101-
All core classes are:
102-
- **Immutable**: State changes create new instances
103-
- **Serializable**: Full conversation state can be saved/restored
104-
- **Type-safe**: Pydantic models ensure data integrity
88+
### SDK – `openhands.sdk`
89+
The core reasoning and execution framework.
90+
Includes conversation management, LLM integration, tool system, workspace abstraction, and event streaming.
91+
92+
**Use when:** Embedding agents directly in Python apps or building custom behaviors programmatically.
93+
94+
### Tools – `openhands.tools`
95+
Production-ready, typed tools implementing the Action/Observation interface.
96+
97+
Examples:
98+
File editors, search utilities, task management, and web interaction tools.
99+
100+
**Use when:** You need common capabilities out-of-the-box or want to define new tools declaratively.
105101

106-
### Modularity
107-
- **Composable**: Mix and match components as needed
108-
- **Extensible**: Add custom tools, LLMs, or workspaces
109-
- **Testable**: Each component can be tested in isolation
102+
### Workspace – `openhands.workspace`
103+
Defines where code executes:
104+
- `LocalWorkspace` – No isolation
105+
- `DockerWorkspace` – Sandboxed execution
106+
- `RemoteAPIWorkspace` – Distributed via REST
110107

111-
### Backward Compatibility
112-
- **Semantic versioning** indicates compatibility levels
113-
- **Migration guides** provided for major changes
108+
**Use when:** You need isolation, resource control, or remote environments.
114109

115-
## Getting Started
110+
### Agent Server – `openhands.agent_server`
111+
A REST+WebSocket server for remote agent execution and workspace orchestration.
116112

117-
New to the SDK? Start with the guides:
113+
**Use when:** Building multi-user, hosted, or SaaS-style agent platforms.
118114

119-
- **[Getting Started](/sdk/guides/getting-started)** - Quick introduction
120-
- **[Streaming Mode](/sdk/guides/streaming-mode)** - Execution patterns
121-
- **[Tools & MCP](/sdk/guides/tools-and-mcp)** - Extending capabilities
122-
- **[Workspaces](/sdk/guides/workspaces)** - Execution environments
123-
- **[Sub-agents](/sdk/guides/subagents)** - Agent delegation
115+
## Execution Models
124116

125-
## Deep Dive
117+
### Local (Standalone)
118+
The SDK runs entirely in your process—ideal for development or embedding in apps.
126119

127-
Explore individual components:
120+
**Flow:**
121+
1. User message → Conversation
122+
2. Agent → LLM → Tool → Workspace
123+
3. Observation → Response
128124

129-
- **SDK Package** - [Tool](/sdk/architecture/sdk/tool) | [Agent](/sdk/architecture/sdk/agent) | [LLM](/sdk/architecture/sdk/llm) | [Conversation](/sdk/architecture/sdk/conversation)
130-
- **Tools Package** - [BashTool](/sdk/architecture/tools/bash) | [FileEditorTool](/sdk/architecture/tools/file_editor)
131-
- **Workspace Package** - [DockerWorkspace](/sdk/architecture/workspace/docker) | [RemoteAPIWorkspace](/sdk/architecture/workspace/remote_api)
132-
- **Agent Server** - [Overview](/sdk/architecture/agent_server/overview)
125+
### Remote (Agent Server)
126+
Agents run inside isolated containers managed by the Agent Server.
127+
Clients interact via a `RemoteConversation` proxy using the same Python API.
133128

134-
## Examples
129+
**Why:** Enables scalable, multi-tenant deployments without changing client code.
135130

136-
Browse the [`examples/`](https://github.com/All-Hands-AI/agent-sdk/tree/main/examples) directory for practical implementations:
131+
---
132+
133+
## Choosing the Right Mode
134+
135+
| Use Case | Recommended Setup |
136+
|-----------|------------------|
137+
| Local dev, automation scripts | Standalone SDK |
138+
| Web apps, hosted agents, SaaS | Agent Server |
139+
| Hybrid (local control + remote exec) | SDK + `RemoteAPIWorkspace` |
140+
141+
---
137142

138-
- **Hello World** - Basic agent usage
139-
- **Custom Tools** - Creating new capabilities
140-
- **Docker Workspace** - Sandboxed execution
141-
- **MCP Integration** - External tool servers
142-
- **Planning Agent** - Multi-step workflows
143+
## Next Steps
144+
- [Getting Started](/sdk/getting-started) – Build your first agent
145+
- [Custom Tools](/sdk/guides/custom-tools) – Add new capabilities
146+
- [MCP Integration](/sdk/guides/mcp) – Connect external tool servers
147+
- [Remote Server](/sdk/guides/agent-server/overview) – Host agents remotely
148+
149+
For in-depth details, explore:
150+
- [`openhands/sdk/`](https://github.com/All-Hands-AI/agent-sdk/tree/main/openhands/sdk)
151+
- [`openhands/tools/`](https://github.com/All-Hands-AI/agent-sdk/tree/main/openhands/tools)
152+
- [`openhands/workspace/`](https://github.com/All-Hands-AI/agent-sdk/tree/main/openhands/workspace)
153+
- [`openhands/agent_server/`](https://github.com/All-Hands-AI/agent-sdk/tree/main/openhands/agent_server)

0 commit comments

Comments
 (0)