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

Function TestResumeAgentIDMismatch

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

Source from the content-addressed store, hash-verified

299}
300
301func 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
338func TestResumeConfirmation(t *testing.T) {
339 ctx := context.Background()

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected