JianFeeeee
e70b7e954c
refactor(toolcall): 批内消息改为「一个 assistant 带全部 tool_calls」(阶段 2a)
问题:现状每个工具各自 append 一对(assistant[tool_calls=[tc]] + tool),
既不表达「这是一批」,也无法支撑并行:
· 产生 N 条 assistant 消息,同一段 assistant 文本语义上只该出现一次
· 并行下完成顺序不确定,若等结果回来再落消息,assistant 就必须等所有
结果齐了才能写——而 OpenAI 协议要求 assistant(tool_calls) 在结果**之前**
改动(task.go):
· TaskFrame 增 assistantMsgIdx
· 新增 ensureBatchAssistant:惰性写入,全批只写**一条** assistant,
携带 f.PendingTools 全部 tool_calls;后续工具只补 tool 消息
· stepToolBegin 的 denied / unhealthy 分支与 stepToolAfter 统一改用它
· stepLLM 设 PendingTools 时清零 assistantMsgIdx
· msgContent 的 ContentOnce 归位移入 ensureBatchAssistant(仍是只挂第一条)
⚠️ 依赖:before_toolcall 阶段**不得**改写工具参数——已核实全仓无此用法
(grep ToolCalls[0].Arguments 赋值无结果)。若将来某插件要改写 args,
需改为「回填后重写该条 assistant」。该前提已写入代码注释。
判据(toolbatch_test.go 追加 TestBatchLayoutSingleAssistantCarriesAllToolCalls):
· 带 tool_calls 的 assistant **恰好一条**且携带 2 个 tool_calls
· 其后紧跟 2 条 tool 消息且按声明顺序(c1、c2)
变异验证:让 ensureBatchAssistant 退化为「每工具一条」⇒ 判据 FAIL
「批内 assistant 应带 2 个 tool_calls,实际 1」。
stage 0.5 补的三条判据(配对完整性 / ContentOnce / denied 后继续)
在本改动后**仍然全绿**——它们正是为这种改动准备的保护网。
回归:internal/agent/... internal/sdk/... internal/plugins/... 全绿(18 包)。
2026-09-27 11:09:02 +08:00
..
2026-09-19 16:49:16 +08:00
2026-09-15 07:47:16 +08:00
2026-09-11 11:45:24 +08:00
2026-09-26 16:19:10 +08:00
2026-09-27 10:56:02 +08:00
2026-09-27 10:56:02 +08:00
2026-09-15 06:32:36 +08:00
2026-09-15 06:32:36 +08:00
2026-09-11 11:45:24 +08:00
2026-09-13 12:23:28 +08:00
2026-09-26 20:16:11 +08:00
2026-09-26 20:09:17 +08:00
2026-08-18 09:07:21 +08:00
2026-09-15 09:03:36 +08:00
2026-09-15 09:16:22 +08:00
2026-09-13 09:06:50 +08:00
2026-09-14 23:14:38 +08:00
2026-09-13 15:41:07 +08:00
2026-09-13 15:35:59 +08:00
2026-09-15 09:37:29 +08:00
2026-09-15 09:37:29 +08:00
2026-07-28 11:42:29 +08:00
2026-09-15 08:13:52 +08:00
2026-09-11 13:45:25 +08:00
2026-09-11 13:45:25 +08:00
2026-09-11 11:45:24 +08:00
2026-09-13 00:25:52 +08:00
2026-09-13 10:36:04 +08:00
2026-09-15 08:13:52 +08:00
2026-09-26 21:55:12 +08:00
2026-09-04 06:25:51 +08:00
2026-09-04 06:25:51 +08:00
2026-09-19 17:47:44 +08:00
2026-09-19 17:43:16 +08:00
2026-09-13 09:13:19 +08:00
2026-09-13 16:04:16 +08:00
2026-09-26 19:11:51 +08:00
2026-09-12 13:57:06 +08:00
2026-09-12 13:57:06 +08:00
2026-09-19 16:49:16 +08:00
2026-08-18 09:07:21 +08:00
2026-09-19 11:57:50 +08:00
2026-09-27 08:55:25 +08:00
2026-09-13 14:34:44 +08:00
2026-09-11 20:31:50 +08:00
2026-09-10 23:59:12 +08:00
2026-09-15 08:13:52 +08:00
2026-09-13 15:09:44 +08:00
2026-09-13 20:19:37 +08:00
2026-09-19 17:43:16 +08:00
2026-09-19 17:47:44 +08:00
2026-09-26 20:09:17 +08:00
2026-09-26 21:55:12 +08:00
2026-09-26 20:09:17 +08:00
2026-09-13 08:59:15 +08:00
2026-09-14 09:05:14 +08:00
2026-09-13 07:00:51 +08:00
2026-09-13 07:18:03 +08:00
2026-09-13 07:00:51 +08:00
2026-09-14 10:39:25 +08:00
2026-09-13 06:10:44 +08:00
2026-09-13 07:00:51 +08:00
2026-09-13 07:00:51 +08:00
2026-09-13 07:31:32 +08:00
2026-09-13 07:00:51 +08:00
2026-09-19 17:47:44 +08:00
2026-09-10 20:36:39 +08:00
2026-09-13 08:59:15 +08:00
2026-09-13 08:59:15 +08:00
2026-09-03 12:37:58 +08:00
2026-07-24 14:49:08 +08:00
2026-09-27 08:55:25 +08:00
2026-09-12 14:56:25 +08:00
2026-09-19 17:43:16 +08:00
2026-09-18 11:39:04 +08:00
2026-09-27 09:17:16 +08:00
2026-09-27 08:55:25 +08:00
2026-09-19 16:49:16 +08:00
2026-09-13 06:24:20 +08:00
2026-09-13 07:00:51 +08:00
2026-09-13 06:17:49 +08:00
2026-09-27 11:09:02 +08:00
2026-09-17 18:56:15 +08:00
2026-09-17 18:56:15 +08:00
2026-09-19 14:24:31 +08:00
2026-09-25 14:45:08 +08:00
2026-09-27 11:09:02 +08:00
2026-09-27 08:55:25 +08:00
2026-09-27 10:56:02 +08:00
2026-09-26 21:55:12 +08:00
2026-09-27 09:17:16 +08:00
2026-09-27 09:17:16 +08:00
2026-09-14 16:45:04 +08:00
2026-09-26 16:19:10 +08:00