From 9f9735c33219667677ad105fa2507a94298e879a Mon Sep 17 00:00:00 2001 From: "Varshini.M.L" Date: Fri, 22 May 2026 14:41:54 +0000 Subject: [PATCH] fix: add MAX_REVISIONS guard to prevent infinite revision loop --- multi_agents/agents/orchestrator.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/multi_agents/agents/orchestrator.py b/multi_agents/agents/orchestrator.py index f835fff702..2fbfbf94cd 100644 --- a/multi_agents/agents/orchestrator.py +++ b/multi_agents/agents/orchestrator.py @@ -74,10 +74,15 @@ def _add_workflow_edges(self, workflow): workflow.add_edge('publisher', END) # Add human in the loop + MAX_REVISIONS = 5 workflow.add_conditional_edges( 'human', - lambda review: "accept" if review['human_feedback'] is None else "revise", - {"accept": "researcher", "revise": "planner"} + lambda state: ( + "accept" if state['human_feedback'] is None + else "force_accept" if state.get('revisions_count', 0) >= MAX_REVISIONS + else "revise" + ), + {"accept": "researcher", "force_accept": "researcher", "revise": "planner"} ) def init_research_team(self):