Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 34 additions & 26 deletions sdk/arch/agent-server.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@

**Decision**: FastAPI
- ✅ Automatic API documentation (OpenAPI)
- ✅ Type validation with Pydantic

Check warning on line 111 in sdk/arch/agent-server.mdx

View check run for this annotation

Mintlify / Mintlify Validation (allhandsai) - vale-spellcheck

sdk/arch/agent-server.mdx#L111

Did you really mean 'Pydantic'?
- ✅ Async support for performance
- ✅ WebSocket support built-in

Expand Down Expand Up @@ -201,7 +201,7 @@
--workers 4
```

**Use case**: Small deployments, prototypes, MVPs

Check warning on line 204 in sdk/arch/agent-server.mdx

View check run for this annotation

Mintlify / Mintlify Validation (allhandsai) - vale-spellcheck

sdk/arch/agent-server.mdx#L204

Did you really mean 'MVPs'?

### 3. Multi-Server Deployment

Expand Down Expand Up @@ -368,39 +368,47 @@
- Resource exhaustion
- Container failures

## Client SDK
## Client Integration Architecture

Python SDK for interacting with Agent Server:
The SDK implements a **workspace-based dispatch pattern** for connecting to agent servers. The `Conversation` factory inspects the workspace type and returns the appropriate conversation implementation.

```python
from openhands.client import AgentServerClient
```mermaid
flowchart LR
Conv["Conversation()"] --> Check{"Workspace Type?"}
Check -->|LocalWorkspace| Local["LocalConversation"]
Check -->|RemoteWorkspace| Remote["RemoteConversation"]
Remote -->|HTTP/WebSocket| Server["Agent Server"]

style Conv fill:#f3e8ff,stroke:#7c3aed,stroke-width:2px
style Remote fill:#e8f3ff,stroke:#2b6cb0,stroke-width:2px
style Server fill:#fff4df,stroke:#b7791f,stroke-width:2px
```

client = AgentServerClient(
url="https://agent-server.example.com",
api_key="your-api-key"
)
### Workspace Types

# Create conversation
conversation = client.create_conversation()
| Workspace | Conversation Type | Communication |
Comment thread
VascoSch92 marked this conversation as resolved.
|-----------|------------------|---------------|
| [`LocalWorkspace`](https://github.com/OpenHands/software-agent-sdk/blob/main/openhands-sdk/openhands/sdk/workspace/local.py) | [`LocalConversation`](https://github.com/OpenHands/software-agent-sdk/blob/main/openhands-sdk/openhands/sdk/conversation/impl/local_conversation.py) | Direct execution |
| [`OpenHandsCloudWorkspace`](https://github.com/OpenHands/software-agent-sdk/blob/main/openhands-workspace/openhands/workspace/cloud/workspace.py) | [`RemoteConversation`](https://github.com/OpenHands/software-agent-sdk/blob/main/openhands-sdk/openhands/sdk/conversation/impl/remote_conversation.py) | HTTPS + WebSocket to OpenHands Cloud |
| [`APIRemoteWorkspace`](https://github.com/OpenHands/software-agent-sdk/blob/main/openhands-workspace/openhands/workspace/remote_api/workspace.py) | [`RemoteConversation`](https://github.com/OpenHands/software-agent-sdk/blob/main/openhands-sdk/openhands/sdk/conversation/impl/remote_conversation.py) | HTTPS + WebSocket to Runtime API |
| [`DockerWorkspace`](https://github.com/OpenHands/software-agent-sdk/blob/main/openhands-workspace/openhands/workspace/docker/workspace.py) | [`RemoteConversation`](https://github.com/OpenHands/software-agent-sdk/blob/main/openhands-sdk/openhands/sdk/conversation/impl/remote_conversation.py) | HTTP + WebSocket to local container |

Comment thread
VascoSch92 marked this conversation as resolved.
# Send message
response = client.send_message(
conversation_id=conversation.id,
message="Hello, agent!"
)
### [`RemoteConversation`](https://github.com/OpenHands/software-agent-sdk/blob/main/openhands-sdk/openhands/sdk/conversation/impl/remote_conversation.py) Responsibilities

# Stream responses
for event in client.stream_conversation(conversation.id):
if event.type == "message":
print(event.content)
```
The `RemoteConversation` implementation handles all client-server concerns:

- **Session management**: Authenticates and maintains connection to agent server
- **Event streaming**: WebSocket connection for real-time agent events
- **Request routing**: HTTP calls for conversation lifecycle operations
- **Reconnection**: Automatic retry logic for transient failures

### Usage Examples

For complete working examples with all required setup:

**Client handles**:
- Authentication
- Request/response serialization
- Error handling
- Streaming
- Retries
- **[OpenHands Cloud Workspace](/sdk/guides/agent-server/cloud-workspace)** - Managed cloud infrastructure
- **[API-based Sandbox](/sdk/guides/agent-server/api-sandbox)** - Custom runtime environments
- **[Docker Sandbox](/sdk/guides/agent-server/docker-sandbox)** - Local containerized execution

## Cost Considerations

Expand Down Expand Up @@ -454,7 +462,7 @@
✅ **Scaling**: Need to handle concurrent users

**Examples**:
- Chatbot platforms

Check warning on line 465 in sdk/arch/agent-server.mdx

View check run for this annotation

Mintlify / Mintlify Validation (allhandsai) - vale-spellcheck

sdk/arch/agent-server.mdx#L465

Did you really mean 'Chatbot'?
- Code assistant web apps
- Agent marketplaces
- Enterprise agent deployments
Expand Down
Loading