# 由 openapi/scripts/generate.php 生成,请勿手改;补充写到 overrides/v3-agent-traces.yaml post: summary: 写入一次提问的研究过程(幂等) tags: - agent-traces operationId: post_api_v3_agent_traces description: |- 请求头 `X-Agent-Service-Key` 证明调用方是 agent 服务;`Authorization: Bearer` 是 agent 透传的终端用户 token(可选):有效的人类 token 记到账号下, 没有 / 失效 / 是模型 token 都记为游客——此时 `device_id` 必填,并记 `client_ip`。 token 失效不拒绝,照样入库。 按 run_id 幂等:首次写入 201,重复提交返回已有记录 200,步骤不会重复写。 实现:`V3\AgentTraceController@store` security: - { } - bearerAuth: [] requestBody: required: true content: application/json: schema: type: object properties: run_id: type: string description: 'AG-UI runId(uuid)' thread_id: type: string description: 'AG-UI threadId(uuid)' device_id: type: string description: '设备匿名 id(uuid)。游客必填,登录用户忽略' client_ip: type: string description: '客户端 IP。只对游客记录' client: type: string description: 客户端 enum: - mobile - web question: type: string description: 用户的提问 status: type: string description: 运行结果(denied=额度不足被拦下) enum: - ok - error - cancelled - denied improve: type: boolean description: 用户是否允许用于改进回答(提问那一刻的开关) default: true steps: type: array description: '每一步(LLM 调用、工具调用、节点事件),最多 500 条' required: - run_id - thread_id - question - status responses: 200: description: 成功 content: application/json: schema: type: object properties: data: type: object properties: run_id: type: string thread_id: type: string account_type: type: string enum: - user - guest created_at: type: string 201: description: '首次写入。响应体与 200 同形' content: application/json: schema: type: object properties: data: type: object properties: run_id: type: string thread_id: type: string account_type: type: string enum: - user - guest created_at: type: string 401: $ref: '../../main.yaml#/components/responses/ProblemUnauthorized' 403: description: 'thread_id 已经属于别的账号' content: application/problem+json: schema: $ref: '../../main.yaml#/components/schemas/ProblemDetails' 422: $ref: '../../main.yaml#/components/responses/ProblemValidation'