(t *testing.T)
| 336 | } |
| 337 | |
| 338 | func 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" |
nothing calls this directly
no test coverage detected