()
| 724 | |
| 725 | #[tokio::test] |
| 726 | async fn loop_stops_when_predicate_says_stop() { |
| 727 | let exec: Arc<dyn AgentExecutor> = Arc::new(EchoExecutor::new()); |
| 728 | let mut rounds = 0; |
| 729 | let out = crate::orchestration::execute_loop( |
| 730 | exec, |
| 731 | vec![AgentStepSpec::new("r0", "explore", "d", "p")], |
| 732 | 10, |
| 733 | None, |
| 734 | |outcomes| { |
| 735 | rounds += 1; |
| 736 | // Continue twice, then stop on the third round. |
| 737 | if rounds < 3 { |
| 738 | LoopDecision::Continue(vec![AgentStepSpec::new( |
| 739 | format!("r{rounds}"), |
| 740 | "explore", |
| 741 | "d", |
| 742 | outcomes[0].output.clone(), |
| 743 | )]) |
| 744 | } else { |
| 745 | LoopDecision::Stop |
| 746 | } |
| 747 | }, |
| 748 | ) |
| 749 | .await; |
| 750 | assert_eq!(rounds, 3, "predicate saw exactly three rounds"); |
| 751 | assert_eq!(out.len(), 1, "returns the last round's outcomes"); |
| 752 | assert!(out[0].success); |
| 753 | } |
| 754 | |
| 755 | #[tokio::test] |
| 756 | async fn loop_is_hard_capped_by_max_iterations() { |
nothing calls this directly
no test coverage detected