(t *testing.T)
| 29 | ) |
| 30 | |
| 31 | func 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", |
nothing calls this directly
no test coverage detected