MCPcopy Index your code
hub / github.com/AI45Lab/Code / loop_stops_when_predicate_says_stop

Function loop_stops_when_predicate_says_stop

core/src/orchestration/combinators.rs:726–753  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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() {

Callers

nothing calls this directly

Calls 1

execute_loopFunction · 0.85

Tested by

no test coverage detected