feat(gateway): 面 1 补齐 —— 消息读取面 toolCalls[](工具回看)
前提由 FV2 提供(图自 v0.77 起带每路 turnId、每路各落一行)。本片:
- 迁移 0023:flow_graphs 加「按路查询键」(写入时回填图的 TurnID),老行按缺席处理
- GET /api/v1/sessions/{id}/messages 加**可选** toolCalls[],形状严格照 Docs/api-client.md
v0.76 ① 已登记的:{name, status(ok|error|unknown), durationMs, argsSummary, resultSummary}
- 🔴 图取不到 ⇒ **字段整体缺席**(绝不回空数组冒充「没调过工具」)
- 一条批量 SQL(按页内 turnId 集合),禁 N+1;单条 ≤20 个工具、resultSummary ≤500 字符(常量+依据)
- 只放图里已有的、已脱敏内容,不放宽脱敏通道
This commit is contained in:
1 parent
99a644d545
commit
c907a34510
10 files changed
+1429
-16
No files matched your search
@@ -106,8 +106,20 @@ type historyMessage struct {
|
||||
// 一路回答尚未确定),因此它们的那一帧 `message_persisted` 不带 turnId ——
|
||||
// 客户端从 `turn_begin`(帧壳 turnId + data.messageIds)得知归属,行本身随后
|
||||
// 由它实际被处理的那一路补写。
|
||||
TurnID string `json:"turnId,omitempty"`
|
||||
CreatedAt int64 `json:"createdAt"`
|
||||
TurnID string `json:"turnId,omitempty"`
|
||||
// ToolCalls 是这条消息所属那**一轮**的工具回看面(契约 v0.76 ①;切片 CODE-TC):
|
||||
// 形状 `[{name,status,durationMs,argsSummary,resultSummary}, ...]`,内容逐字来自
|
||||
// **已落盘的轮次链路图**(`flow_graphs`),因此是出图时**已脱敏**的那一份。
|
||||
//
|
||||
// 🔴 缺席语义:该键**只在这条消息真的回看到工具调用时才出现**。图取不到
|
||||
// (超保留期 / 该轮未落盘 / 隔离渠道会话从不入库 / 该路标识查不到图)、以及这一路
|
||||
// 确实没调过工具,都是**键缺席** —— **绝不**回 `[]` 冒充「没调过工具」。客户端
|
||||
// 因此只能做正向断言:「有这个键 ⇒ 这一轮调用过工具」。
|
||||
//
|
||||
// 它**只由读接口填充**(`handleListMessages`):其余共用本结构的出口
|
||||
// (`message_persisted` / `message_edited` / 握手回放 / 渠道日志)逐字不变。
|
||||
ToolCalls []historyToolCall `json:"toolCalls,omitempty"`
|
||||
CreatedAt int64 `json:"createdAt"`
|
||||
}
|
||||
|
||||
// handleHistorySessions 先返回主会话,再返回每个子会话(最旧
|
||||
@@ -283,6 +295,10 @@ func (s *Server) handleListMessages(w http.ResponseWriter, r *http.Request) {
|
||||
for _, m := range msgs {
|
||||
out = append(out, toHistoryMessage(m))
|
||||
}
|
||||
// 工具回看面(契约 v0.76 ①;切片 CODE-TC):只在本端点补,且**一次批量查图**
|
||||
// (按页内路标识集合,禁 N+1)。图取不到 ⇒ 字段整体缺席(attachToolCalls 只在
|
||||
// 真的回看到工具调用时才写),绝不回空数组。
|
||||
s.attachToolCalls(r.Context(), id, out)
|
||||
writeJSON(w, http.StatusOK, out)
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user