MCPcopy
hub / github.com/google/ax / TestTaskManager

Function TestTaskManager

internal/controller/executor/executor_test.go:68–102  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

66}
67
68func 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
104func TestFanout(t *testing.T) {
105 ctx := context.Background()

Callers

nothing calls this directly

Calls 5

AgentFuncFunction · 0.85
textFunction · 0.85
DefaultExecutorFunction · 0.85
memoryEventLogFunction · 0.85
ExecMethod · 0.65

Tested by

no test coverage detected