package builtin // agent_test.go -- honesty regression for the Agent-tool dead-executor // fallback. When no AgentExecutor is wired the sub-agent does NOT run; the // fallback previously returned IsError:false, so the model treated the dropped // delegation as a successful sub-agent run (病根 #1: fake-success no-op). The // fix flips it to IsError:true. (The real wire lives in engine.New via // SetupAgentExecutor; this test locks the no-executor path's honesty.) // // agent_test.go -- Agent 工具死执行器 fallback 的诚实化回归. 无 AgentExecutor 接 // 线时子 agent 根本没跑; fallback 原返 IsError:false, 模型把被丢弃的委派当成功 // 的子 agent 运行 (病根 #1: 假成功 no-op). 修复翻成 IsError:true. (真 wire 在 // engine.New 经 SetupAgentExecutor; 本测试锁无 executor 路径的诚实.) import ( "context" "encoding/json" "strings" "testing" "git.flytoex.net/yuanwei/flyto-agent/core/pkg/tools" ) func TestAgentTool_NoExecutor_FallbackIsError(t *testing.T) { tool := NewAgentTool(tools.NewRegistry()) // no executor set -> fallback path input := json.RawMessage(`{"prompt":"do something","description":"x","mode":"sync"}`) res, err := tool.Execute(context.Background(), input, nil) if err != nil { t.Fatalf("Execute: %v", err) } if !res.IsError { t.Fatal("no-executor fallback reported IsError=false (fake success) -- the model would treat the dropped sub-agent work as done") } if !strings.Contains(res.Output, "not available") { t.Fatalf("fallback output unexpected: %q", res.Output) } }