AGENT SKILL
agent-server 会话创建 API
agent-server-api
如何通过 agent-server REST API 创建会话。当把编码任务委派给 agent-server 或启动新的智能体会话时使用。
- 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
DigitalOcean 服务器环境指南
this-environment
运行于 oh.rbren.io 的 DigitalOcean 云服务器(部署 openhands-remote)的完整指南——涵盖硬件、网络、应用、认证、DNS,以及如何添加新内容。
★ 0
Agent 技能创建指南
skill-creator
用于创建高效技能的指南,通过专业知识、工作流或工具集成扩展智能体能力。当用户想要创建或更新技能时使用。
★ 0
重新思考
rethink
当我让你重新思考时,使用此技能。
★ 0
Slack 片段频道笔记
rbren-snippets
#rbren-snippets Slack 频道(ID:C0APBQYQTFV)是 Robert 的个人草稿本,用于记录想法、观察、bug 笔记和开发环境更新。
★ 0
nginx 配置与管理
nginx
openhands-remote 中 nginx 的配置和管理方式。
★ 0
本地项目路径查询
local-projects
本地项目存储在 ~/git/ 目录中。
★ 0