v3-agent-traces.yaml 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. # 由 openapi/scripts/generate.php 生成,请勿手改;补充写到 overrides/v3-agent-traces.yaml
  2. post:
  3. summary: 写入一次提问的研究过程(幂等)
  4. tags:
  5. - agent-traces
  6. operationId: post_api_v3_agent_traces
  7. description: |-
  8. 请求头 `X-Agent-Service-Key` 证明调用方是 agent 服务;`Authorization: Bearer`
  9. 是 agent 透传的终端用户 token(可选):有效的人类 token 记到账号下,
  10. 没有 / 失效 / 是模型 token 都记为游客——此时 `device_id` 必填,并记 `client_ip`。
  11. token 失效不拒绝,照样入库。
  12. 按 run_id 幂等:首次写入 201,重复提交返回已有记录 200,步骤不会重复写。
  13. 实现:`V3\AgentTraceController@store`
  14. security:
  15. - { }
  16. -
  17. bearerAuth: []
  18. requestBody:
  19. required: true
  20. content:
  21. application/json:
  22. schema:
  23. type: object
  24. properties:
  25. run_id:
  26. type: string
  27. description: 'AG-UI runId(uuid)'
  28. thread_id:
  29. type: string
  30. description: 'AG-UI threadId(uuid)'
  31. device_id:
  32. type: string
  33. description: '设备匿名 id(uuid)。游客必填,登录用户忽略'
  34. client_ip:
  35. type: string
  36. description: '客户端 IP。只对游客记录'
  37. client:
  38. type: string
  39. description: 客户端
  40. enum:
  41. - mobile
  42. - web
  43. question:
  44. type: string
  45. description: 用户的提问
  46. status:
  47. type: string
  48. description: 运行结果(denied=额度不足被拦下)
  49. enum:
  50. - ok
  51. - error
  52. - cancelled
  53. - denied
  54. improve:
  55. type: boolean
  56. description: 用户是否允许用于改进回答(提问那一刻的开关)
  57. default: true
  58. steps:
  59. type: array
  60. description: '每一步(LLM 调用、工具调用、节点事件),最多 500 条'
  61. required:
  62. - run_id
  63. - thread_id
  64. - question
  65. - status
  66. responses:
  67. 200:
  68. description: 成功
  69. content:
  70. application/json:
  71. schema:
  72. type: object
  73. properties:
  74. data:
  75. type: object
  76. properties:
  77. run_id:
  78. type: string
  79. thread_id:
  80. type: string
  81. account_type:
  82. type: string
  83. enum:
  84. - user
  85. - guest
  86. created_at:
  87. type: string
  88. 201:
  89. description: '首次写入。响应体与 200 同形'
  90. content:
  91. application/json:
  92. schema:
  93. type: object
  94. properties:
  95. data:
  96. type: object
  97. properties:
  98. run_id:
  99. type: string
  100. thread_id:
  101. type: string
  102. account_type:
  103. type: string
  104. enum:
  105. - user
  106. - guest
  107. created_at:
  108. type: string
  109. 401:
  110. $ref: '../../main.yaml#/components/responses/ProblemUnauthorized'
  111. 403:
  112. description: 'thread_id 已经属于别的账号'
  113. content:
  114. application/problem+json:
  115. schema:
  116. $ref: '../../main.yaml#/components/schemas/ProblemDetails'
  117. 422:
  118. $ref: '../../main.yaml#/components/responses/ProblemValidation'