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

Function TestResumeConfirmation

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

Source from the content-addressed store, hash-verified

336}
337
338func TestResumeConfirmation(t *testing.T) {
339 ctx := context.Background()
340 eventLog := memoryEventLog()
341
342 msg := &proto.Message{
343 Content: &proto.Content{
344 Type: &proto.Content_Confirmation{
345 Confirmation: &proto.ConfirmationContent{
346 Id: "test-conf-id",
347 Question: "proceed?",
348 },
349 },
350 },
351 }
352
353 var runCount int
354 registry := map[string]agent.Agent{
355 "root": AgentFunc(func(inputs []*proto.Message, tm agent.Executor, o agent.OutputHandler) {
356 if conf := historyutil.WaitsForConfirmation(inputs); conf != nil {
357 o(&proto.AgentOutputs{
358 Messages: []*proto.Message{msg},
359 })
360 return
361 }
362
363 approved, _ := historyutil.HasConfirmationAnswer(inputs)
364 if approved {
365 if err := o(&proto.AgentOutputs{
366 // "Hello!" is responded with a confirmation request.
367 Messages: []*proto.Message{{
368 Content: &proto.Content{
369 Type: &proto.Content_Text{
370 Text: &proto.TextContent{
371 Text: "awesome!",
372 },
373 },
374 },
375 }},
376 }); err != nil {
377 t.Fatal(err)
378 }
379 }
380
381 if runCount == 0 {
382 runCount++
383 if err := o(&proto.AgentOutputs{
384 // "Hello!" is responded with a confirmation request.
385 Messages: []*proto.Message{msg},
386 }); err != nil {
387 t.Fatal(err)
388 }
389 }
390 }),
391 }
392
393 tm := DefaultExecutor(eventLog, registry)
394
395 // First run: starts as "root"

Callers

nothing calls this directly

Calls 10

WaitsForConfirmationFunction · 0.92
HasConfirmationAnswerFunction · 0.92
memoryEventLogFunction · 0.85
AgentFuncFunction · 0.85
DefaultExecutorFunction · 0.85
textFunction · 0.85
GetConfirmationMethod · 0.80
GetContentMethod · 0.80
ExecMethod · 0.65
GetTextMethod · 0.45

Tested by

no test coverage detected