genworker

genworker API Guide

1. Overview

genworker 默认暴露一组面向本地 Agent Runtime 的 HTTP 接口,核心能力集中在:

默认服务地址:

http://127.0.0.1:8000

2. Core Endpoints

2.1 Chat Stream

POST /api/v1/chat/stream
Content-Type: application/json

用途:

典型请求体:

{
  "message": "你好,帮我总结今天的任务重点",
  "thread_id": "chat-001",
  "tenant_id": "demo",
  "worker_id": "analyst-01"
}

2.2 Worker Task Stream

POST /api/v1/worker/task/stream
Content-Type: application/json

用途:

典型请求体:

{
  "task": "检查我的收件箱并整理待办",
  "tenant_id": "demo",
  "worker_id": "analyst-01"
}

2.3 Health

GET /health

用途:

2.4 Readiness

GET /readiness

用途:

2.5 Runtime Debug

GET /api/v1/debug/runtime

用途:

3. Authentication

如果你启用了以下任一配置,API 将进入鉴权模式:

示例:

curl -s http://127.0.0.1:8000/api/v1/debug/runtime \
  -H "Authorization: Bearer your-token"

4. Streaming Notes

/api/v1/chat/stream/api/v1/worker/task/stream 默认是流式接口。

调用方需要注意:

5. Quick Verification

curl -s http://127.0.0.1:8000/health
curl -s http://127.0.0.1:8000/readiness
curl -s http://127.0.0.1:8000/api/v1/debug/runtime

6. Troubleshooting

6.1 /health 正常但 /readiness 失败

说明进程已启动,但默认运行链路尚未准备完成。优先检查:

6.2 流式接口在代理后不返回增量

优先检查代理层是否启用了响应缓冲。对于 Nginx,这通常意味着需要关闭 proxy_buffering