Skip to content

Commit 64f58d5

Browse files
committed
audited local server
1 parent 6424cbc commit 64f58d5

1 file changed

Lines changed: 11 additions & 20 deletions

File tree

sdk/guides/agent-server/local-agent-server.mdx renamed to sdk/guides/agent-server/local-server.mdx

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Local Agent Server
33
description: Run agents through a local HTTP server with RemoteConversation for client-server architecture.
44
---
55

6-
The Local Agent Server demonstrates how to run a remote agent server locally and connect to it using RemoteConversation. This enables separation between client code and agent execution, making it possible to run agents on dedicated servers or different machines.
6+
The Local Agent Server demonstrates how to run a remote agent server locally and connect to it using RemoteConversation. This pattern is useful for local development, testing, and scenarios where you want to separate the client code from the agent execution environment.
77

88
## Basic Example
99

@@ -294,20 +294,21 @@ The server starts with `python -m openhands.agent_server` and automatically hand
294294

295295
### Remote Workspace
296296

297-
When using a remote server, you need to provide a `Workspace` that connects to that server:
297+
When connecting to a remote server, you need to provide a `Workspace` that connects to that server:
298298

299-
```python highlight={157-158}
299+
```python
300300
workspace = Workspace(host=server.base_url)
301301
result = workspace.execute_command("pwd")
302302
```
303303

304+
When `host` is provided, the `Workspace` returns an instance of `RemoteWorkspace` ([source](https://github.com/All-Hands-AI/agent-sdk/blob/main/openhands-sdk/openhands/sdk/workspace/workspace.py)).
304305
The `Workspace` object communicates with the remote server's API to execute commands and manage files.
305306

306307
### RemoteConversation
307308

308-
When you pass a remote `Workspace` to `Conversation`, it automatically becomes a `RemoteConversation`:
309+
When you pass a remote `Workspace` to `Conversation`, it automatically becomes a `RemoteConversation` ([source](https://github.com/All-Hands-AI/agent-sdk/blob/main/openhands-sdk/openhands/sdk/conversation/conversation.py)):
309310

310-
```python highlight={164-170}
311+
```python
311312
conversation = Conversation(
312313
agent=agent,
313314
workspace=workspace,
@@ -323,7 +324,7 @@ RemoteConversation handles communication with the remote agent server over WebSo
323324

324325
Callbacks receive events in real-time as they happen on the remote server:
325326

326-
```python highlight={148-153}
327+
```python
327328
def event_callback(event):
328329
"""Callback to capture events for testing."""
329330
event_type = type(event).__name__
@@ -338,7 +339,7 @@ This enables monitoring agent activity, tracking progress, and implementing cust
338339

339340
The conversation state provides access to all events and status:
340341

341-
```python highlight={208-214}
342+
```python
342343
# Count total events using state.events
343344
total_events = len(conversation.state.events)
344345
logger.info(f"📈 Total events in conversation: {total_events}")
@@ -350,18 +351,8 @@ recent_events = all_events[-5:] if len(all_events) >= 5 else all_events
350351

351352
This allows you to inspect the conversation history, analyze agent behavior, and build custom monitoring tools.
352353

353-
## When to Use Local Agent Server
354-
355-
The local agent server pattern is useful when you want to:
356-
357-
- **Separate Concerns**: Keep client code separate from agent execution
358-
- **Development**: Test remote conversation features locally
359-
- **Multi-Client**: Allow multiple clients to connect to the same server
360-
- **Debugging**: Inspect server logs and behavior independently
361-
- **Preparation**: Prepare code for deploying to a real remote server
362-
363354
## Next Steps
364355

365-
- **[Docker Sandboxed Server](/sdk/guides/agent-server/docker-sandboxed-server)** - Run server in Docker for isolation
366-
- **[API Sandboxed Server](/sdk/guides/agent-server/api-sandboxed-server)** - Connect to hosted API service
367-
- **[Agent Server Architecture](/sdk/arch/agent_server/overview)** - Deep dive into server internals
356+
- **[Docker Sandboxed Server](/sdk/guides/agent-server/docker-sandbox)** - Run server in Docker for isolation
357+
- **[API Sandboxed Server](/sdk/guides/agent-server/api-sandbox)** - Connect to hosted API service
358+
- **[Agent Server Package Architecture](/sdk/arch/agent-server-package)** - Architecture and design decisions

0 commit comments

Comments
 (0)