I’ve noticed that when I try to use or_
in a flow to listen to multiple methods, the listening method is only executed once during the flow, when it should be executed at least once per method it listens to.
For example, when running the following example from the CrewAI documentation locally, the logger method is only executed once.
from crewai.flow.flow import Flow, listen, or_, start
class OrExampleFlow(Flow):
@start()
def start_method(self):
return "Hello from the start method"
@listen(start_method)
def second_method(self):
return "Hello from the second method"
@listen(or_(start_method, second_method))
def logger(self, result):
print(f"Logger: {result}")
flow = OrExampleFlow()
flow.kickoff()
Per the documentation, the or_
function in Flows allows you to listen to multiple methods and trigger the listener method when any of the specified methods emit an output, and therefore, in this case we would expect the logger method to be executed twice.
Can anyone explain why or_
is not working as expected?