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

Function TestMulti

internal/multi_test.go:31–145  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

29)
30
31func TestMulti(t *testing.T) {
32 ctx := context.Background()
33 input := "Send the word 'oRanGe' to the local-echo-agent. Take its exact output and send it to the remote-text-processor. Take its exact output and send it to the uppercase agent. Return the final output."
34 execID := uuid.New().String()
35
36 // 1. Create local agents with specific behaviors to make the test self-contained.
37 echoAgent, err := createLocalAgent(func(s string) string { return strings.ToLower(s) })
38 if err != nil {
39 t.Fatalf("Error creating local agent: %v", err)
40 }
41
42 remoteAgent, err := createLocalAgent(func(s string) string { return "Remote Prefix: " + s })
43 if err != nil {
44 t.Fatalf("Error creating remote agent: %v", err)
45 }
46
47 uppercaseAgent, err := createLocalAgent(func(s string) string { return "UPPERCASE: " + strings.ToUpper(s) })
48 if err != nil {
49 t.Fatalf("Error creating uppercase agent: %v", err)
50 }
51
52 // 2. Initialize controller
53 dbPath := filepath.Join(t.TempDir(), "test_multi.db")
54 c, err := controller.New(ctx, controller.Config{
55 EventLogBuilder: func() (executor.EventLog, error) {
56 return executor.OpenSQLiteEventLog(dbPath)
57 },
58 PlannerBuilder: func(ctx context.Context, r *controller.Registry) (agent.Agent, error) {
59 return &mockPlanner{}, nil
60 },
61 })
62 if err != nil {
63 t.Fatalf("Error creating controller: %v", err)
64 }
65 defer c.Close()
66
67 // 3. Register Agents
68 if err := c.Registry().RegisterLocal(config.LocalAgentConfig{
69 ID: "local-echo-agent",
70 Name: "Local Echo Agent",
71 Description: "Converts text to lowercase",
72 Agent: echoAgent,
73 }); err != nil {
74 t.Fatalf("Error registering local agent: %v", err)
75 }
76
77 if err := c.Registry().RegisterLocal(config.LocalAgentConfig{
78 ID: "remote-text-processor",
79 Name: "Remote Text Processor",
80 Description: "Adds the prefix 'Remote Prefix: ' to the text",
81 Agent: remoteAgent,
82 }); err != nil {
83 t.Fatalf("Error registering remote agent: %v", err)
84 }
85
86 if err := c.Registry().RegisterLocal(config.LocalAgentConfig{
87 ID: "uppercase",
88 Name: "Uppercase Agent",

Callers

nothing calls this directly

Calls 11

NewFunction · 0.92
OpenSQLiteEventLogFunction · 0.92
ExecHandlerFuncType · 0.92
createLocalAgentFunction · 0.85
RegisterLocalMethod · 0.80
RegistryMethod · 0.80
GetContentMethod · 0.80
CloseMethod · 0.65
ExecMethod · 0.65
StringMethod · 0.45
GetTextMethod · 0.45

Tested by

no test coverage detected