Replies: 1 comment
-
|
yeah multiple routers definitely work in crewAI flows - you just need each one wired up correctly. the "function does not have state" error usually means the router method is not accessing state the right way. make sure you are using minimal working example with two routers: from crewai.flow.flow import Flow, listen, router, start
from pydantic import BaseModel
class MyState(BaseModel):
step: str = ""
outcome: str = ""
class MyFlow(Flow[MyState]):
@start()
def first_step(self):
self.state.step = "completed"
@router(first_step)
def route_one(self):
if self.state.step == "completed":
return "branch_a"
return "branch_b"
@listen("branch_a")
def branch_a_handler(self):
self.state.outcome = "a"
@router(branch_a_handler)
def route_two(self):
if self.state.outcome == "a":
return "finish"
return "retry"
@listen("finish")
def finish_handler(self):
print("done")things to double check:
if you paste your actual code i can see exactly what is tripping it up |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
As soon as I add a 2nd @router, the flow complains about "function does not have state".
Is it known that a flow can only have 1 router?
Please help, thanks.
Beta Was this translation helpful? Give feedback.
All reactions