agent-server-api
How to create conversations via the agent-server REST API. Use when delegating coding tasks to agent-server or spawning new agent conversations.
- License 许可
- MIT
- 所属仓库
- rbren/dotfiles
- 最近更新
- 2026-05-08
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- agent-server-api
- license
- MIT
- description
- How to create conversations via the agent-server REST API. Use when delegating coding tasks to agent-server or spawning new agent conversations.
03 SKILL.md 正文
Agent Server API — Creating Conversations
Server Locations
- Primary (conversations app):
http://localhost:4004 - Vibe app:
http://localhost:4041 - Source code:
~/git/software-agent-sdk/openhands-agent-server/
Authentication
- Header:
X-Session-API-Key - Value comes from env var
OH_SESSION_API_KEYS_0
Create a Conversation
POST /api/conversations
Minimal Payload
{
"agent": {
"llm": {
"model": "anthropic/claude-sonnet-4-20250514",
"api_key": "<ANTHROPIC_API_KEY>"
},
"tools": [{"name": "terminal"}, {"name": "file_editor"}]
},
"workspace": {
"type": "local",
"working_dir": "/path/to/project"
},
"initial_message": {
"role": "user",
"content": [{"type": "text", "text": "Your task description here"}],
"run": true
}
}
Key Fields
| Field | Required | Notes |
|---|---|---|
agent.llm.model |
yes | Format: provider/model-name |
agent.llm.api_key |
yes | Use $ANTHROPIC_API_KEY from env |
agent.tools |
yes | Array of {"name": "..."} objects. Common: terminal, file_editor, browser_tool_set, task_tracker, delegate |
workspace.type |
yes | Always "local" on this machine |
workspace.working_dir |
yes | Absolute path to the project root |
initial_message |
no | If provided with "run": true, agent starts immediately |
initial_message.content |
— | Array of {"type": "text", "text": "..."} objects |
max_iterations |
no | Default 500. Cap to prevent runaway agents |
conversation_id |
no | UUID. Auto-generated if omitted |
confirmation_policy |
no | Defaults to NeverConfirm() |
secrets |
no | Dict of secret name → source |
autotitle |
no | Default true. Auto-generates title from first message |
Example curl
curl -s -X POST http://localhost:4004/api/conversations \
-H 'Content-Type: application/json' \
-H "X-Session-API-Key: $AGENT_SERVER_API_KEY" \
-d '{
"agent": {
"llm": {
"model": "anthropic/claude-sonnet-4-20250514",
"api_key": "'"$ANTHROPIC_API_KEY"'"
},
"tools": [{"name": "terminal"}, {"name": "file_editor"}]
},
"workspace": {
"type": "local",
"working_dir": "/root/git/my-project"
},
"initial_message": {
"role": "user",
"content": [{"type": "text", "text": "Fix the bug in main.py"}],
"run": true
},
"max_iterations": 100
}'
Response
Returns ConversationInfo with status 201 (new) or 200 (existing):
{
"id": "uuid-here",
"status": "running",
"workspace": { "type": "local", "working_dir": "..." },
...
}
Other Useful Endpoints
| Method | Path | Description |
|---|---|---|
| GET | /api/conversations/search |
List/search conversations |
| POST | /api/conversations/{id}/message |
Send message to existing conversation |
| POST | /api/conversations/{id}/pause |
Pause a conversation |
| POST | /api/conversations/{id}/resume |
Resume a paused conversation |
| DELETE | /api/conversations/{id} |
Delete a conversation |
| GET | /api/conversations/{id}/events |
Get conversation events |
Notes
- The
working_dirin workspace is where the agent's terminal starts and where file operations are rooted "run": trueon the initial message means the agent loop starts automatically after receiving the message- Conversations persist across agent-server restarts via
meta.jsonfiles - Terminal sessions use tmux (
tmux -Lopenhandssocket) — these can leak if cleanup fails (see known bugs in the codebase)
04 同仓库更多 Skills
this-environment
Complete guide to this DigitalOcean droplet running openhands-remote at oh.rbren.io — hardware, networking, apps, auth, DNS, and how to add new things
skill-creator
Guide for creating effective skills that extend agent capabilities with specialized knowledge, workflows, or tool integrations. Use when the user wants to create or update a skill.
rethink
When I tell you to rethink, use this skill
rbren-snippets
The #rbren-snippets Slack channel (ID: C0APBQYQTFV) is Robert's personal scratchpad for thoughts, observations, bug notes, and dev environment updates.
nginx
How nginx is configured and managed for openhands-remote
local-projects
local projects are stored in ~/git/