返回 DeepSeek-Reasonix
plan_decision_feedback_test.go
根目录 / internal / control / plan_decision_feedback_test.go
1 package control
2
3 import (
4 "path/filepath"
5 "testing"
6
7 "reasonix/internal/agent"
8 "reasonix/internal/event"
9 "reasonix/internal/provider"
10 )
11
12 func TestResolvePlanDecisionStagesRevisionBeforeAnswer(t *testing.T) {
13 session := agent.NewSession("sys")
14 session.Add(provider.Message{Role: provider.RoleAssistant, Content: "proposed plan"})
15 c := newOwnedTestController(t, Options{Executor: agent.New(nil, nil, session, agent.Options{}, event.Discard), WorkspaceRoot: t.TempDir()})
16 c.SetSessionPath(filepath.Join(c.workspaceRoot, "session.jsonl"))
17 id, reply := c.approval.registerDecisionKind(planApprovalTool, "", "", true, false, "plan", nil)
18 if err := c.ResolvePlanDecisionWithFeedback(id, PlanDecisionRevisePlan, "cover the rollback path"); err != nil {
19 t.Fatal(err)
20 }
21 if got := <-reply; got.allow {
22 t.Fatal("revise_plan unexpectedly allowed execution")
23 }
24 snap := c.InboxSnapshot()
25 if len(snap.Items) != 1 {
26 t.Fatalf("inbox items = %+v", snap.Items)
27 }
28 _, envelope, err := c.ReadInboxItem(snap.Items[0].ID)
29 if err != nil {
30 t.Fatal(err)
31 }
32 if envelope.SubmitText != "cover the rollback path" || snap.Items[0].Idempotency != "plan-revision:"+id {
33 t.Fatalf("revision = %+v / %+v", snap.Items[0], envelope)
34 }
35 }
36
36 lines GO