Course Content
CrewAI Multi-Agents
9 sections · 53 lessons
How does CrewAI support collaboration between agents?
What you need to know
Channel 1: task outputs
When a task finishes, its output (text, and optionally a Pydantic object) is stored. The next task's prompt includes earlier outputs as context.
- If a task does not set
context, a sequential crew passes it all earlier task outputs joined together. - If it sets
context=[research_task], it gets only that output. context=[]gives it none.
Channel 2: delegation
With allow_delegation=True, CrewAI adds two tools to the agent:
- Delegate work to coworker — arguments:
task,context,coworker. - Ask question to coworker — arguments:
question,context,coworker.
The coworker value is matched against other agents' role (ignoring case and extra spaces). The coworker starts fresh and knows nothing else, so the delegating agent must put everything needed into context. Delegation is off by default in current CrewAI.
Channel 3: a manager
In Process.hierarchical, a manager agent receives each task and delegates it to the right worker, checks the result and can ask for rework. This is delegation organised from the top.
Channel 4: shared background
memory=Trueon the crew gives agents a shared store that is written after tasks and recalled before them.knowledge_sources=[...]on the crew lets every agent search the same documents.
Explicit context
- You decide which output goes where
- Same path every run
- One LLM loop per task
- Easy to debug from the task list
Delegation
- The agent decides whom to ask
- Path can change between runs
- Each delegation is another LLM loop
- Needs traces to debug
A real-life example
A content team crew has a researcher, a writer and an editor.
The first version gave all three allow_delegation=True. The editor kept delegating "check this fact" back to the researcher, who re-ran searches, and one article triggered 14 extra LLM loops. The cost per post tripled.
The fix: turn delegation off for all three and wire the work explicitly. The writer gets context=[research_task]. The editor gets context=[research_task, draft_task], so it can check facts against the research without searching again. Only one case kept delegation: the writer may ask a question of the researcher when a fact is missing, which happens in about one post in ten. Cost went back to normal and runs became repeatable.
Follow-up questions to expect
- "Do agents share memory while running?" — Not live. They see each other's work through task outputs, delegation results, and the memory store that is written after tasks complete.
- "What happens if the coworker name is wrong?" — The tool returns an error listing the valid coworkers, and the agent usually retries; it costs an extra step, so keep role names short and distinct.
- "How do you stop agents delegating in circles?" — Keep
allow_delegation=Falseon specialists, set a lowmax_iter, and prefer explicitcontext.