(t *testing.T)
| 299 | } |
| 300 | |
| 301 | func TestResumeAgentIDMismatch(t *testing.T) { |
| 302 | ctx := context.Background() |
| 303 | eventLog := memoryEventLog() |
| 304 | |
| 305 | registry := map[string]agent.Agent{ |
| 306 | "root": AgentFunc(func(inputs []*proto.Message, tm agent.Executor, o agent.OutputHandler) { |
| 307 | // Do nothing to leave it in PENDING state |
| 308 | }), |
| 309 | "other": AgentFunc(func(inputs []*proto.Message, tm agent.Executor, o agent.OutputHandler) { |
| 310 | }), |
| 311 | } |
| 312 | |
| 313 | tm := DefaultExecutor(eventLog, registry) |
| 314 | |
| 315 | // First run: starts as "root" |
| 316 | if _, err := tm.Exec(ctx, "test-conv", "task1", &proto.AgentStart{ |
| 317 | AgentId: "root", |
| 318 | Messages: []*proto.Message{text("user", "hello!")}, |
| 319 | }, nil); err != nil { |
| 320 | t.Fatal(err) |
| 321 | } |
| 322 | |
| 323 | // Second run: attempts to resume as "other" for same execID "task1" |
| 324 | _, err := tm.Exec(ctx, "test-conv", "task1", &proto.AgentStart{ |
| 325 | AgentId: "other", |
| 326 | Messages: []*proto.Message{text("user", "hello again!")}, |
| 327 | }, nil) |
| 328 | |
| 329 | if err == nil { |
| 330 | t.Fatal("expected error due to agent ID mismatch, got nil") |
| 331 | } |
| 332 | |
| 333 | if !strings.Contains(err.Error(), "resumption not allowed") { |
| 334 | t.Fatalf("expected 'resumption not allowed' error, got: %v", err) |
| 335 | } |
| 336 | } |
| 337 | |
| 338 | func TestResumeConfirmation(t *testing.T) { |
| 339 | ctx := context.Background() |
nothing calls this directly
no test coverage detected