
Crewai Multi Agent
Design CrewAI Flows with typed state, @start/@listen/@router branching, and hybrid Crew steps for event-driven multi-agent apps.
Install
npx skills add https://github.com/orchestra-research/ai-research-skills --skill crewai-multi-agentWhat is this skill?
- Compares Crews vs Flows: branching, state, and event-driven control favor Flows
- Typed Pydantic state on Flow subclasses with kickoff and final state access
- @start, @listen, @router, or_, and and_ decorators for execution paths
- Supports multiple parallel @start entry points
- Hybrid pattern: embed Crews inside individual Flow steps
Adoption & trust: 1 installs on skills.sh; 9.4k GitHub stars; 2/3 security scanners passed (skills.sh audits).
Recommended Skills
Microsoft Foundrymicrosoft/azure-skills
Azure Aimicrosoft/azure-skills
Azure Hosted Copilot Sdkmicrosoft/azure-skills
Lark Eventlarksuite/cli
Running Claude Code Via Litellm Copilotxixu-me/skills
Setup Matt Pocock Skillsmattpocock/skills
Journey fit
Primary fit
Flow orchestration is authored while building agent products—the canonical shelf is Build agent-tooling even when you later operate those flows in production. Agent-tooling is where frameworks, decorators, and execution graphs are chosen before Ship hardening.
Common Questions / FAQ
Is Crewai Multi Agent safe to install?
skills.sh reports 2 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.
SKILL.md
READMESKILL.md - Crewai Multi Agent
# CrewAI Flows Guide ## Overview Flows provide event-driven orchestration with precise control over execution paths, state management, and conditional branching. Use Flows when you need more control than Crews provide. ## When to Use Flows vs Crews | Scenario | Use Crews | Use Flows | |----------|-----------|-----------| | Simple multi-agent collaboration | ✅ | | | Sequential/hierarchical tasks | ✅ | | | Conditional branching | | ✅ | | Complex state management | | ✅ | | Event-driven workflows | | ✅ | | Hybrid (Crews inside Flow steps) | | ✅ | ## Flow Basics ### Creating a Flow ```python from crewai.flow.flow import Flow, listen, start, router, or_, and_ from pydantic import BaseModel # Define state model class MyState(BaseModel): counter: int = 0 data: str = "" results: list = [] # Create flow with typed state class MyFlow(Flow[MyState]): @start() def initialize(self): """Entry point - runs first""" self.state.counter = 1 return {"initialized": True} @listen(initialize) def process(self, data): """Runs after initialize completes""" self.state.counter += 1 return f"Processed: {data}" # Run flow flow = MyFlow() result = flow.kickoff() print(flow.state.counter) # Access final state ``` ### Flow Decorators #### @start() - Entry Point ```python @start() def begin(self): """First method(s) to execute""" return {"status": "started"} # Multiple start points (run in parallel) @start() def start_a(self): return "A" @start() def start_b(self): return "B" ``` #### @listen() - Event Trigger ```python # Listen to single method @listen(initialize) def after_init(self, result): """Runs when initialize completes""" return process(result) # Listen to string name @listen("high_confidence") def handle_high(self): """Runs when router returns 'high_confidence'""" pass ``` #### @router() - Conditional Branching ```python @router(analyze) def decide_path(self): """Returns string to route to specific listener""" if self.state.confidence > 0.8: return "high_confidence" elif self.state.confidence > 0.5: return "medium_confidence" return "low_confidence" @listen("high_confidence") def handle_high(self): pass @listen("medium_confidence") def handle_medium(self): pass @listen("low_confidence") def handle_low(self): pass ``` #### or_() and and_() - Conditional Combinations ```python from crewai.flow.flow import or_, and_ # Triggers when EITHER condition is met @listen(or_("success", "partial_success")) def handle_any_success(self): pass # Triggers when BOTH conditions are met @listen(and_(task_a, task_b)) def after_both_complete(self): pass ``` ## State Management ### Pydantic State Model ```python from pydantic import BaseModel, Field from typing import Optional class WorkflowState(BaseModel): # Required fields input_data: str # Optional with defaults processed: bool = False confidence: float = 0.0 results: list = Field(default_factory=list) error: Optional[str] = None # Nested models metadata: dict = Field(default_factory=dict) class MyFlow(Flow[WorkflowState]): @start() def init(self): # Access state print(self.state.input_data) # Modify state self.state.processed = True self.state.results.append("item") self.state.metadata["timestamp"] = "2025-01-01" ``` ### State Initialization ```python # Initialize with inputs flow = MyFlow() result = flow.kickoff(inputs={"input_data": "my data"}) # Or set state before kickoff flow.state.input_data = "my data" result = flow.kickoff() ``` ## Integrating Crews in Flows ### Crew as Flow Step ```python from crewai import Crew, Agent, Task, Process from crewai.flow.flow import Flow, listen, start class ResearchFlow(Flow[ResearchState]): @start() def gather_requirements(self): return {"topic": self.state.topic}