You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 64f58d5
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: sdk/guides/agent-server/local-server.mdx
+11-20Lines changed: 11 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@ title: Local Agent Server
3
3
description: Run agents through a local HTTP server with RemoteConversation for client-server architecture.
4
4
---
5
5
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.
7
7
8
8
## Basic Example
9
9
@@ -294,20 +294,21 @@ The server starts with `python -m openhands.agent_server` and automatically hand
294
294
295
295
### Remote Workspace
296
296
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:
298
298
299
-
```python highlight={157-158}
299
+
```python
300
300
workspace = Workspace(host=server.base_url)
301
301
result = workspace.execute_command("pwd")
302
302
```
303
303
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)).
304
305
The `Workspace` object communicates with the remote server's API to execute commands and manage files.
305
306
306
307
### RemoteConversation
307
308
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)):
309
310
310
-
```python highlight={164-170}
311
+
```python
311
312
conversation = Conversation(
312
313
agent=agent,
313
314
workspace=workspace,
@@ -323,7 +324,7 @@ RemoteConversation handles communication with the remote agent server over WebSo
323
324
324
325
Callbacks receive events in real-time as they happen on the remote server:
325
326
326
-
```python highlight={148-153}
327
+
```python
327
328
defevent_callback(event):
328
329
"""Callback to capture events for testing."""
329
330
event_type =type(event).__name__
@@ -338,7 +339,7 @@ This enables monitoring agent activity, tracking progress, and implementing cust
338
339
339
340
The conversation state provides access to all events and status:
340
341
341
-
```python highlight={208-214}
342
+
```python
342
343
# Count total events using state.events
343
344
total_events =len(conversation.state.events)
344
345
logger.info(f"📈 Total events in conversation: {total_events}")
0 commit comments