Files
sundynix-agentix/sundynix-dispatcher/internal/eino/agent_collab_test.go
T
Blizzard ef6f525a74 refactor(dispatcher): T1.1 退役 graph.go —— 编排引擎收成单一 compose
compose 已默认数天、HITL/多智能体/评测全在其上真实跑过,soak 充分。删掉自研拓扑
解释器这第二套引擎,消灭"双实现 drift"税:

- 删 runGraph(graph.go 的自研解释器)+ composeEnabled/EINO_COMPOSE 逃生舱开关
  + runConversation(仅 runGraph 用的死代码)。
- executeGraph 直接走 runComposeGraph;compose 编译失败兜底改单轮对话(不再回退
  graph.go);清掉仅 runGraph 用的 import(otel attribute/trace/otelx)。
- 保留 board / 各节点执行器(retriever/tool/agent/branch/approval/map/render/aggregate)
  / 工具函数 —— 它们是 compose 各节点 lambda 复用的,非 graph.go 专属。
- 测试:8 处 runGraph→runComposeGraph;等价测试(对照两引擎)转为 compose 正确性测试;
  runConversation 的开关测试转为「无 ChatModel 降级 runAgent」。

go test ./... 全绿 + vet 干净;冒烟 简单 agent/分支图 跑通。此后每个编排改动不再两边
对齐,成本减半。DEPTH_ROADMAP T1.1 。

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-30 08:53:02 +08:00

47 lines
1.5 KiB
Go

package eino
import (
"context"
"strings"
"testing"
"github.com/sundynix/sundynix-dispatcher/internal/harness"
"github.com/sundynix/sundynix-dispatcher/internal/llm"
"github.com/sundynix/sundynix-shared/contract"
)
// TestAgentCollaborationPassesOutput 验证编排式多智能体接力:
// agent1 的产出注入 agent2 的上下文,agent2 基于它继续;最终成稿 = 下游 agent 的产出。
func TestAgentCollaborationPassesOutput(t *testing.T) {
graph := `{"version":"1","nodes":[
{"id":"a1","kind":"agent","config":{"system":"研究"}},
{"id":"a2","kind":"agent","config":{"system":"撰写"}}
],"edges":[{"source":"a1","target":"a2"}]}`
saw := false
ll := &fakeLLM{ready: true, stream: func(m []llm.ChatMessage) string {
var sys string
for _, x := range m {
if x.Role == "system" {
sys = x.Content
}
}
if strings.Contains(sys, "研究产出XYZ") { // agent1 的产出出现在 agent2 的 system → 接力成功
saw = true
return "最终报告:基于上游研究撰写"
}
return "研究产出XYZ"
}}
o := &Orchestrator{pool: ll, breaker: harness.NewCircuitBreaker(), sink: &fakeSink{}}
ans, _, err := o.runComposeGraph(context.Background(), &contract.Task{ID: "tc", Graph: []byte(graph)}, &execTracer{})
if err != nil {
t.Fatal(err)
}
if !saw {
t.Fatal("下游 agent 未看到上游 agent 的产出——协作没接力")
}
if !strings.Contains(ans, "最终报告") {
t.Fatalf("最终成稿应为下游 agent 产出,得 %q", ans)
}
}