feat(agent): get_worker_trace 的 step_ids 超限改为降级返回而非报错
原先 step_ids 超过 5 个直接报错,逼 Agent 重新组织调用、白跑一轮。改为优雅 降级:先去重、剔除非法 id,超出 5 个则返回前 5 步的完整内容,并在结果里用 returned_step_ids / omitted_step_ids / notice 告知本次取了哪些、还有哪些没取, 并提示「若已足够则无需再取剩余」。Agent 立刻拿到数据,是否再取由它自行判断。 保留数量上限的原因不变:detail 是完整原文、不截断,上限用于兜住单个 tool result 的大小。get_task_worker_trace 经 delegateToTask 复用同一实现,一并生效; 两处工具描述同步更新。 验证: 新增 TestGetWorkerTraceStepIDsDegradeGracefully(含去重/非法 id/前5/ omitted/notice/在限内不加提示),连本地 PG 实跑通过;agent 全量无回归。
This commit is contained in:
1 parent
6a8e13fcbd
commit
412a993c25
4 files changed
+106
-9
No files matched your search
@@ -345,11 +345,11 @@ func (s *Server) toolAddHint() actool.CoreTool {
|
||||
|
||||
func (s *Server) toolGetWorkerTrace() actool.CoreTool {
|
||||
return roTool("get_task_worker_trace",
|
||||
"看指定任务里某个 work(意图)的执行过程:get_task_worker_trace(task_id, intent_id) 看步骤摘要;再带 step_ids=[...] 取那几步完整内容(一次≤5)。",
|
||||
"看指定任务里某个 work(意图)的执行过程:get_task_worker_trace(task_id, intent_id) 看步骤摘要;再带 step_ids=[...] 取那几步完整内容(一次最多 5 个,多传只返回前 5 个)。",
|
||||
objSchema(map[string]any{
|
||||
"task_id": strParam("任务 id"),
|
||||
"intent_id": map[string]any{"type": "integer", "description": "意图 id(该任务里的 work)"},
|
||||
"step_ids": map[string]any{"type": "array", "items": map[string]any{"type": "integer"}, "description": "可选:要取完整内容的步骤 id(≤5)"},
|
||||
"step_ids": map[string]any{"type": "array", "items": map[string]any{"type": "integer"}, "description": "可选:要取完整内容的步骤 id(一次最多 5 个,多传只返回前 5 个,其余在 omitted_step_ids 里列出)"},
|
||||
}, "task_id", "intent_id"),
|
||||
func(ctx context.Context, in json.RawMessage) (actool.Result, error) {
|
||||
return s.delegateToTask(ctx, in, (*agent.ToolSet).GetWorkerTraceTool)
|
||||
|
||||
Reference in new issue
Block a user