CrewAI Flow Basics: Orchestrate Multiple Crews in a Controlled Workflow

2 min read

When your process becomes "research -> writing -> review -> publish", a single crew is not enough.
Flow acts as the control tower that coordinates multiple crews.

What problems does Flow solve?

  • Manage multi-step state
  • Handle branching logic (publish on pass, rerun on fail)
  • Improve observability and maintainability

Minimal Flow example

from pydantic import BaseModel
from crewai.flow.flow import Flow, start, listen, router
 
class BlogState(BaseModel):
    topic: str = ""
    draft: str = ""
    word_count: int = 0
 
class BlogFlow(Flow[BlogState]):
    @start()
    def init_topic(self) -> str:
        self.state.topic = "CrewAI for beginners"
        return self.state.topic
 
    @listen(init_topic)
    def write_draft(self, topic: str) -> str:
        result = "draft content..."
        self.state.draft = result
        self.state.word_count = len(result.split())
        return result
 
    @router(write_draft)
    def quality_gate(self) -> str:
        return "ok" if self.state.word_count > 100 else "retry"

Flow design suggestions

  1. Keep each @listen method focused on one job
  2. Keep branching in @router, avoid large if/else blocks everywhere
  3. Use typed BaseModel state, not raw dict

With this style, you can revisit the code after six months without feeling like an archaeologist.

When should you use Flow?

  • Workflow has more than 3 steps
  • Clear branch conditions exist
  • Multiple crews need coordination

If your workflow is just "research + report writing," a single crew is enough.

Next step

After workflow orchestration, the next common question is: "Will agents remember context?"
Next post covers memory and knowledge sources:
👉 Memory and Knowledge