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

Function Example

internal/controller/executor/executor_test.go:38–66  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

36}
37
38func Example() {
39 ctx := context.Background()
40
41 registry := map[string]agent.Agent{
42 "planner": AgentFunc(func(inputs []*proto.Message, tm agent.Executor, o agent.OutputHandler) {
43 if _, err := tm.Exec(ctx, "test-conv", "deep-research-task", &proto.AgentStart{
44 AgentId: "deep-research",
45 Messages: inputs,
46 }, o); err != nil {
47 return
48 }
49
50 if _, err := tm.Exec(ctx, "test-conv", "pub-med-lookup-task", &proto.AgentStart{
51 AgentId: "pub-med-index",
52 Messages: inputs,
53 }, o); err != nil {
54 return
55 }
56 }),
57 }
58
59 tm := DefaultExecutor(memoryEventLog(), registry)
60 if _, err := tm.Exec(ctx, "test-conv", "test", &proto.AgentStart{
61 AgentId: "planner",
62 Messages: []*proto.Message{text("user", "Hello, I'd like to research cancer treatment options.")},
63 }, nil); err != nil {
64 log.Fatal(err)
65 }
66}
67
68func TestTaskManager(t *testing.T) {
69 ctx := context.Background()

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected