446b784fc6
补 Harness 已知洞:此前 LLM-judge 只看 input+output,看不到检索来源,幻觉其实没评。 - Evaluator.Score 增 sources 参数;有来源时走 llmJudgeGrounded:一次调用同时评 quality 质量 + faithfulness 忠实度,并列出 unsupported(未被来源支持的说法)→ 进 Flags。 综合分(有来源)=0.3规则+0.35质量+0.35忠实;无来源时维持原 0.4规则+0.6质量。Result 增 Faithful 字段。 - 透传检索来源:runGraph 返回 (answer, refs, err),executeGraph 同步;Handle→evaluate(input,output,refs); refsOf(board)=检索资料+工具产出。compose 路径暂返回 nil refs(不评忠实度)。 - eval 日志增「忠实 X.XX,来源 N」。 测试:单测覆盖 grounded(quality/faithfulness/unsupported 解析 + 加权 + flags)与无来源跳过; 3 处测试 runGraph 三返回值更新。live 实测 RAG 任务忠实 1.00/来源 1,judge 正确判定无编造。 project_analysis Harness 清单勾掉该项。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
47 lines
1.5 KiB
Go
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.runGraph(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)
|
|
}
|
|
}
|