(t *testing.T)
| 66 | } |
| 67 | |
| 68 | func TestTaskManager(t *testing.T) { |
| 69 | ctx := context.Background() |
| 70 | |
| 71 | registry := map[string]agent.Agent{ |
| 72 | "root": AgentFunc(func(inputs []*proto.Message, tm agent.Executor, o agent.OutputHandler) { |
| 73 | if _, err := tm.Exec(ctx, "test-conv", "child-task", &proto.AgentStart{ |
| 74 | AgentId: "child", |
| 75 | Messages: inputs, |
| 76 | }, o); err != nil { |
| 77 | t.Fatal(err) |
| 78 | } |
| 79 | if o != nil { |
| 80 | o(&proto.AgentOutputs{ |
| 81 | Messages: []*proto.Message{text("assistant", "root done")}, |
| 82 | }) |
| 83 | } |
| 84 | }), |
| 85 | "child": AgentFunc(func(inputs []*proto.Message, tm agent.Executor, o agent.OutputHandler) { |
| 86 | time.Sleep(100 * time.Millisecond) |
| 87 | if o != nil { |
| 88 | o(&proto.AgentOutputs{ |
| 89 | Messages: []*proto.Message{text("assistant", "child done")}, |
| 90 | }) |
| 91 | } |
| 92 | }), |
| 93 | } |
| 94 | |
| 95 | tm := DefaultExecutor(memoryEventLog(), registry) |
| 96 | if _, err := tm.Exec(ctx, "test-conv", "root-task", &proto.AgentStart{ |
| 97 | AgentId: "root", |
| 98 | Messages: []*proto.Message{text("user", "hello!")}, |
| 99 | }, nil); err != nil { |
| 100 | t.Fatal(err) |
| 101 | } |
| 102 | } |
| 103 | |
| 104 | func TestFanout(t *testing.T) { |
| 105 | ctx := context.Background() |
nothing calls this directly
no test coverage detected