Files
weichenandCursor 110c2e810c feat(stageflow): own task/stage types so coordinator drops bizdev
Coordinator now takes a StageTaskRunner and injected context/KB ports.
Chatflow assembler reads maturity tokens instead of the orchestration root.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-15 11:13:17 +00:00

88 lines
2.8 KiB
Go

package coordinator_test
import (
"context"
"strings"
"testing"
"chat-agent-system/internal/coordinator"
"chat-agent-system/internal/intent"
"chat-agent-system/internal/maturity"
)
func TestEngine_IntentPlan_QueryThenQuery(t *testing.T) {
intent.SetFeatureFlagsForTest(intent.FeatureFlags{MultiIntentEnabled: true})
defer intent.ResetFeatureFlagsForTest()
rec := intent.NewRecognizer()
engine := coordinator.NewCoordinatorEngine(nil)
recRes, err := rec.Recognize(context.Background(), "查一下项目风险,然后查相关法规", nil)
if err != nil {
t.Fatalf("recognize: %v", err)
}
if recRes.IntentPlan == nil {
t.Fatal("expected intent plan")
}
userCtx := &coordinator.UserProjectContext{
User: coordinator.UserInfo{ID: "1", Name: "用户"},
Project: coordinator.ProjectInfo{Name: "测试项目", CurrentStage: maturity.StageV01_Triage},
BlackboardFacts: map[string]string{},
}
res, err := engine.ProcessIntent(context.Background(), recRes, userCtx)
if err != nil {
t.Fatalf("ProcessIntent: %v", err)
}
if !strings.Contains(res.NaturalReply, "步骤") {
t.Errorf("expected multi-step reply, got: %s", res.NaturalReply)
}
if res.AdvisorBrief == nil {
t.Fatal("expected AdvisorBrief on multi-intent plan result")
}
}
func TestEngine_ExpectationPlusNew_ExecutesQueryKeepsConfirm(t *testing.T) {
intent.SetFeatureFlagsForTest(intent.FeatureFlags{MultiIntentEnabled: true})
defer intent.ResetFeatureFlagsForTest()
rec := intent.NewRecognizer()
engine := coordinator.NewCoordinatorEngine(nil)
ctx := &intent.ContextSnapshot{
CurrentStage: string(maturity.StageV01_Triage),
PendingExpectation: &intent.PendingExpectation{
ExpectedIntent: intent.IntentAdvanceStage,
AllowAffirmative: true,
DefaultOption: &intent.ExpectationOption{
OptionID: "1",
Intent: intent.IntentAdvanceStage,
Slots: map[string]string{intent.SlotTargetStage: "V0.5_feasibility"},
},
},
}
recRes, err := rec.Recognize(context.Background(), "好,请先查法规", ctx)
if err != nil {
t.Fatalf("recognize: %v", err)
}
userCtx := &coordinator.UserProjectContext{
User: coordinator.UserInfo{ID: "1", Name: "用户"},
Project: coordinator.ProjectInfo{Name: "项目", CurrentStage: maturity.StageV01_Triage},
PendingExpectation: ctx.PendingExpectation,
BlackboardFacts: map[string]string{},
}
res, err := engine.ProcessIntent(context.Background(), recRes, userCtx)
if err != nil {
t.Fatalf("ProcessIntent: %v", err)
}
if !strings.Contains(res.NaturalReply, "法规") && !strings.Contains(res.NaturalReply, "步骤") {
t.Errorf("expected regulation query in reply: %s", res.NaturalReply)
}
if !strings.Contains(res.NaturalReply, "确认") {
t.Errorf("expected confirm note for pending advance: %s", res.NaturalReply)
}
}