From ae22e456ce4ebfbbb54de7529b64e7909ed28513 Mon Sep 17 00:00:00 2001 From: Autumn-27 <53844290+Autumn-27@users.noreply.github.com> Date: Thu, 10 Sep 2026 10:19:19 -0400 Subject: [PATCH] =?UTF-8?q?refactor(tools):=20get=5Fworker=5Foutput=20?= =?UTF-8?q?=E7=A7=BB=E9=99=A4=20terminated=20=E4=B8=8E=20worker=5Fname=20?= =?UTF-8?q?=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit terminated 仅凭有无 result 记录推断,会把运行中(尚无最终结论)的 work 误报为 terminated=true,语义不可靠;worker_name 对调用方也无实际用途。 两字段一并从返回中删除,并同步更新工具描述。 --- agent/tools.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/agent/tools.go b/agent/tools.go index 421b8ea..22afc98 100644 --- a/agent/tools.go +++ b/agent/tools.go @@ -1882,7 +1882,7 @@ func (t *ToolSet) steerWorkTool() actool.CoreTool { // getWorkerOutput returns a work's final (or截至中止时的) conclusion text by intent id. func (t *ToolSet) getWorkerOutput() actool.CoreTool { - return readTool("get_worker_output", "取本任务或直接关联任务某条意图(work)的最终输出结论。关联任务结果带 source_task_id/inherited=true 且只读。正常结束返回其总结;被终止(stopped)/异常的 work 返回其截至中止时的最后输出(terminated=true)。", + return readTool("get_worker_output", "取本任务或直接关联任务某条意图(work)的最终输出结论。关联任务结果带 source_task_id/inherited=true 且只读。正常结束返回其总结;被终止(stopped)/异常的 work 返回其截至中止时的最后输出。", obj(map[string]any{"intent_id": idp("意图 id(= work 句柄)")}, "intent_id"), func(_ context.Context, in json.RawMessage) (actool.Result, error) { var a struct { @@ -1914,14 +1914,14 @@ func (t *ToolSet) getWorkerOutput() actool.CoreTool { fallback = &acts[i] } } - pick, terminated := chosen, false + pick := chosen if pick == nil { - pick, terminated = fallback, true + pick = fallback } if pick == nil { if intentNode.Inherited { return jsonResult(inheritedMap(map[string]any{ - "intent_id": id, "final_text": "(该 work 尚无任何输出)", "terminated": true, + "intent_id": id, "final_text": "(该 work 尚无任何输出)", }, intentNode.SourceTaskID)) } return actool.Text("(该 work 尚无任何输出)"), nil @@ -1931,8 +1931,8 @@ func (t *ToolSet) getWorkerOutput() actool.CoreTool { detail = pick.Summary } result := map[string]any{ - "intent_id": id, "worker_name": pick.Worker, "final_text": detail, - "summary": pick.Summary, "is_error": pick.IsError, "terminated": terminated, + "intent_id": id, "final_text": detail, + "summary": pick.Summary, "is_error": pick.IsError, } if intentNode.Inherited { inheritedMap(result, intentNode.SourceTaskID)