Build and run agents you can see, understand and trust.
Python agentchatbotlarge-language-modelsllmllm-agentmcpmulti-agentmulti-modalreact-agentrealtime-agentvoice-agentvoice-assistant
fix(pipeline): scope the goal pipeline retry budget to one output generation (#3463)
Wilson_Jiang9162517cf435
diff --git a/src/agentscope/pipeline/_goal_pipeline.py b/src/agentscope/pipeline/_goal_pipeline.pyindex 142e44cb1..7322ddf65 100644--- a/src/agentscope/pipeline/_goal_pipeline.py+++ b/src/agentscope/pipeline/_goal_pipeline.py@@ -246,6 +246,9 @@ class GoalPipeline:# The executor parked, so there is nothing to verify yet.break+ # Each report gets its own retry budget.+ self._executor_retries = 0+# Verifierfinal_msg = Noneinstruction = verifier_inputs or UserMsg(@@ -335,6 +338,7 @@ class GoalPipeline:"pass","impossible",):+ self._verifier_retries = 0if final_msg.structured_output["result"] == "impossible":logger.info("The verifier judged the goal impossible: %s",@@ -343,6 +347,7 @@ class GoalPipeline:# Settled either way, so the loop ends here.break_loop = Trueelse:+ self._verifier_retries = 0self._iters += 1if self.verifier_reset_context:# Only the conversation, tool/task state staysdiff --git a/tests/pipeline_goal_test.py b/tests/pipeline_goal_test.pyindex b22c1321e..3bde56ef6 100644--- a/tests/pipeline_goal_test.py+++ b/tests/pipeline_goal_test.py@@ -377,6 +377,46 @@ class GoalPipelineTest(IsolatedAsyncioTestCase):(1, 3),)+ async def test_executor_can_retry_in_each_round(self) -> None:+ """Each report can use the full retry budget."""+ missing = _no_output("executor")+ first, second = _report("v1"), _report("v2")+ executor = StubAgent(+ "executor",+ [[missing], [first], [missing], [second]],+ )+ verifier = StubAgent(+ "verifier",+ [[_verdict("fail", "fix it")], [_verdict("pass")]],+ )+ pipe = GoalPipeline(executor, verifier, max_retries=1)++ yielded = await self._run(pipe, self.query)++ self.assertEqual(yielded, [missing, first, missing, second])+ self.assertEqual(+ (len(executor.received), len(verifier.received)),+ (4, 2),+ )++ async def test_verifier_can_retry_in_each_round(self) -> None:+ """Each verdict can use the full retry budget."""+ first, second = _report("v1"), _report("v2")+ executor = StubAgent("executor", [[first], [second]])+ verifier = StubAgent(+ "verifier",+ [[], [_verdict("fail", "fix it")], [], [_verdict("pass")]],+ )+ pipe = GoalPipeline(executor, verifier, max_retries=1)++ yielded = await self._run(pipe, self.query)++ self.assertEqual(yielded, [first, second])+ self.assertEqual(+ (len(executor.received), len(verifier.received)),+ (2, 4),+ )+async def test_a_fresh_run_restarts_the_retry_budget(self) -> None:"""Each participant can retry again after a previous run failed."""for participant in ("executor", "verifier"):