Skip to content

Framework for orchestrating role-playing, autonomous AI agents. By fostering collaborative intelligence, CrewAI empowers agents to work together seamlessly, tackling complex tasks.

fix: handle HumanFeedbackPending in flow error management (#4200)

João Mourad71e91e8f2bc
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)