From d71e91e8f2bc57a2f41c9b21cc587844910ac577 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Moura?= Date: Wed, 7 Jan 2026 19:52:38 -0800 Subject: [PATCH] fix: handle HumanFeedbackPending in flow error management (#4200) Updated the flow error handling to treat HumanFeedbackPending as expected control flow rather than an error. This change ensures that the flow can appropriately manage human feedback scenarios without signaling an error, improving the robustness of the flow execution. --- lib/crewai/src/crewai/flow/flow.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/crewai/src/crewai/flow/flow.py b/lib/crewai/src/crewai/flow/flow.py index ade5b6f1b..ba5f2291f 100644 --- a/lib/crewai/src/crewai/flow/flow.py +++ b/lib/crewai/src/crewai/flow/flow.py @@ -1203,7 +1203,13 @@ class Flow(Generic[T], metaclass=FlowMeta): result = self.kickoff(inputs=inputs) result_holder.append(result) except Exception as e: - signal_error(state, e) + # HumanFeedbackPending is expected control flow, not an error + from crewai.flow.async_feedback.types import HumanFeedbackPending + + if isinstance(e, HumanFeedbackPending): + result_holder.append(e) + else: + signal_error(state, e) finally: self.stream = True signal_end(state) @@ -1258,7 +1264,13 @@ class Flow(Generic[T], metaclass=FlowMeta): result = await self.kickoff_async(inputs=inputs) result_holder.append(result) except Exception as e: - signal_error(state, e, is_async=True) + # HumanFeedbackPending is expected control flow, not an error + from crewai.flow.async_feedback.types import HumanFeedbackPending + + if isinstance(e, HumanFeedbackPending): + result_holder.append(e) + else: + signal_error(state, e, is_async=True) finally: self.stream = True signal_end(state, is_async=True)