返回 DeepSeek-Reasonix
standard_todo_continuation_test.go
根目录 / internal / agent / standard_todo_continuation_test.go
1 package agent
2
3 import (
4 "context"
5 "reasonix/internal/event"
6 "reasonix/internal/provider"
7 "reasonix/internal/tool"
8 "testing"
9 )
10
11 func standardTodoTestAgent(t *testing.T, turns [][]provider.Chunk) (*Agent, *scriptedProvider) {
12 t.Helper()
13 todoWrite, ok := tool.LookupBuiltin("todo_write")
14 if !ok {
15 t.Fatal("todo_write builtin not registered")
16 }
17 reg := tool.NewRegistry()
18 reg.Add(fakeTool{name: "write_file", readOnly: false})
19 reg.Add(todoWrite)
20 prov := &scriptedProvider{name: "p", turns: turns}
21 return New(prov, reg, NewSession("stable-system-prefix"), Options{}, event.Discard), prov
22 }
23
24 func TestOrdinaryTurnDoesNotContinueForPendingTodos(t *testing.T) {
25 a, prov := standardTodoTestAgent(t, [][]provider.Chunk{
26 {toolCallChunk("todo", "todo_write", `{"todos":[{"content":"Edit code","status":"in_progress"}]}`), {Type: provider.ChunkDone}},
27 {{Type: provider.ChunkText, Text: "I will edit it next."}, {Type: provider.ChunkDone}},
28 {{Type: provider.ChunkText, Text: "must not be consumed"}, {Type: provider.ChunkDone}},
29 })
30 if err := a.Run(context.Background(), "make the change"); err != nil {
31 t.Fatal(err)
32 }
33 if prov.call != 2 {
34 t.Fatalf("provider calls=%d, want todo plus final", prov.call)
35 }
36 todos := a.CanonicalTodoState()
37 if len(todos) != 1 || todos[0].Status != "in_progress" {
38 t.Fatalf("todo facts changed: %+v", todos)
39 }
40 }
41
41 lines GO