本项目要建设一个智能体中台,用于配置、开发、发布智能体能力,并将能力以应用形式开放给外部系统调用。
第一阶段的目标不是重新搭建一套运行时,而是在当前 auto-platform 已有多服务架构上补齐应用开放闭环:
当前仓库已有 api-gateway、agent-service、session-service、auth-service、model-gateway-service、tool-service、skill-service、team-service 等服务。本设计优先复用这些服务边界,不另起一套重复平台。
应用是对外发布单元。外部调用方不需要理解内部 Agent、Session、Run、Tool 的细节,只需要知道应用编码、调用地址和 API Key。
一个应用至少包含:
draft、published、disabled。agent、team,后续扩展 workflow。API Key 用于外部系统调用应用接口。
设计原则:
当前 api-gateway 已有 API Key 生成、hash、prefix、状态、过期时间等基础字段,可在此基础上扩展应用绑定关系。
外部调用分为两类:
V0.1 必须支持 Agent 流式调用。Team 流式能力如果当前链路不足,先在 V0.2 补齐;V0.1 的 Team 调用可先走同步路径。
推荐调用路径:
External Client
-> api-gateway
-> API Key validation
-> Application resolution
-> session-service
-> agent-service / team-service
-> model-gateway-service / tool-service / skill-service / memory-service
-> api-gateway
-> External Client
服务职责:
api-gateway:统一开放入口、API Key 校验、应用解析、限流、审计、SSE 代理。auth-service:用户、角色和后台管理权限;后续可承接更完整的凭证治理。session-service:会话、消息、run request 的持久化和状态管理。agent-service:Agent 定义、配置、运行和 Agent 流式执行。team-service:多 Agent 团队定义和运行。model-gateway-service:统一模型供应商和模型调用。tool-service、skill-service:工具、技能和 MCP 能力绑定。当前代码中 agent-service 已存在 POST /runs/{agent_run_id}/execute-stream,可返回 text/event-stream。api-gateway 的通用代理也已有 SSE 转发能力,但 /gateway/sessions/execute 在 stream=true 时仍返回未实现。因此应用级流式接口需要作为 V0.1 补齐重点。
建议新增应用实体:
app_definition
- id
- code
- name
- description
- status
- target_type
- target_id
- owner_user_id
- settings_json
- created_time
- updated_time
target_type 首版支持:
agentteam后续支持:
workflowsettings_json 可保存:
stream_enableddefault_inputstimeout_secondsrate_limitmetadata建议扩展或新增应用 Key 关系:
app_api_key
- id
- app_id
- name
- key_prefix
- key_hash
- status
- scopes
- expires_time
- last_used_time
- created_time
- updated_time
scope 首版可以保持简单:
app:invokeapp:streamapp:adminV0.1 只需要 app:invoke 和 app:stream。
建议新增调用审计:
app_invocation_audit
- id
- app_id
- api_key_prefix
- request_id
- session_id
- run_request_id
- target_type
- target_id
- invoke_type
- status
- duration_ms
- error_code
- error_message
- client_metadata_json
- created_time
invoke_type:
syncstream管理端接口通过后台登录态访问,不直接使用外部 API Key。
POST /gateway/apps
POST /gateway/apps/list
POST /gateway/apps/detail
POST /gateway/apps/update
POST /gateway/apps/status
创建应用请求示例:
{
"code": "customer_support",
"name": "Customer Support",
"description": "External customer support assistant.",
"target_type": "agent",
"target_id": "agent_support",
"settings_json": {
"stream_enabled": true,
"timeout_seconds": 120
}
}
POST /gateway/apps/{app_id}/api-keys
POST /gateway/apps/{app_id}/api-keys/list
POST /gateway/apps/{app_id}/api-keys/status
创建 Key 请求示例:
{
"name": "production integration",
"scopes": "app:invoke app:stream",
"expires_time": null
}
创建 Key 响应示例:
{
"id": "key_001",
"name": "production integration",
"key_prefix": "agp_xxxxxxxx",
"api_key": "agp_full_plaintext_key_returned_once",
"status": "active",
"scopes": "app:invoke app:stream",
"expires_time": null,
"created_time": "2026-05-14T10:00:00Z"
}
外部调用统一走 api-gateway,请求头支持两种形式:
Authorization: Bearer agp_xxx
或:
X-API-Key: agp_xxx
POST /gateway/openapi/apps/{app_code}/chat
Content-Type: application/json
Authorization: Bearer agp_xxx
请求体:
{
"user_id": "external-user-001",
"session_id": "optional-session-id",
"message": "帮我查询订单状态",
"inputs": {
"order_no": "SO123456"
},
"metadata": {
"source": "crm",
"trace_id": "external-trace-001"
}
}
响应体:
{
"request_id": "req_001",
"app_code": "customer_support",
"session_id": "ses_001",
"run_request_id": "run_req_001",
"target_type": "agent",
"target_id": "agent_support",
"status": "completed",
"output_text": "订单 SO123456 当前正在运输中。",
"output_json": null,
"error": null
}
POST /gateway/openapi/apps/{app_code}/chat/stream
Content-Type: application/json
Accept: text/event-stream
Authorization: Bearer agp_xxx
请求体与同步调用保持一致。
响应类型:
Content-Type: text/event-stream
Cache-Control: no-cache
X-Accel-Buffering: no
事件示例:
event: started
data: {"request_id":"req_001","session_id":"ses_001","run_request_id":"run_req_001"}
event: delta
data: {"text":"订单 "}
event: delta
data: {"text":"SO123456 当前正在运输中。"}
event: completed
data: {"status":"completed","output_text":"订单 SO123456 当前正在运输中。"}
失败事件示例:
event: failed
data: {"status":"failed","error_code":"model_error","error_message":"model request failed"}
V0.1 的流式调用必须满足:
新增“应用”模块,建议放在主导航中,与 Agents、Teams、Skills、Tools、Models 同级。
列表展示:
主要操作:
详情页包含四个区域:
推荐表单步骤:
首版不做复杂向导,保持一个表单和一个详情页即可。
V0.1 必须完成:
V0.1 暂不做:
文档交付验收:
docs/agent-platform-application-api-plan.md。后续实现验收: