Course Content
CrewAI Multi-Agents
9 sections · 53 lessons
How do you break down a complex problem into multiple CrewAI tasks?
What you need to know
Three tests for a task boundary
- Checkable — you can write an
expected_outputand ideally a schema for it. - Coherent — one skill, one set of tools, one credential.
- Describable — you can say what its output looks like in one sentence.
Example: a due-diligence memo on a startup
- gather_public_data — filings, funding, headcount; search and scrape tools; outputs typed facts.
- analyse_market — market size and competitors;
context=[gather_public_data];async_execution=True. - analyse_risks — legal and financial risks;
context=[gather_public_data];async_execution=True. - write_memo —
context=[analyse_market, analyse_risks]; writer agent;output_pydantic=Memo. - review_memo — critic agent;
context=[gather_public_data, write_memo]; a structured verdict.
Tasks 2 and 3 do not depend on each other, so they run at the same time. Task 4 waits for both.
1market = Task(description="...", expected_output="...", agent=analyst,2 context=[facts], async_execution=True)3risks = Task(description="...", expected_output="...", agent=risk_analyst,4 context=[facts], async_execution=True)5memo = Task(description="...", expected_output="...", agent=writer,6 context=[market, risks], output_pydantic=Memo)When to stop splitting
- Each task adds a prompt (persona, description, context) and at least one model call.
- Each handoff can lose information, because only the output text crosses over.
- Merge tasks that always succeed or fail together, such as "extract fields" and "format fields".
When a crew is the wrong container
If the plan needs "if the score is above 70, do X, else Y" or "repeat until approved", use a Flow: @router for the branch, plain Python for the loop, and small crews inside the steps.
A real-life example
A loan-document review crew started with 9 tasks: one per document field plus checks. It took 4 minutes and about Rs 22 per application, and information was often lost between tasks — the "employer name" task did not know which payslip page the "salary" task used.
The team regrouped by document and skill:
- extract_payslips and extract_bank_statement — parallel, one agent each.
- check_policy — joins both, outputs
PolicyResult. - write_credit_note — the officer's summary.
Four tasks instead of nine. Time fell to about 90 seconds, cost to about Rs 9, and cross-field errors dropped because each extraction saw its whole document. Applications with a failed policy check are now routed by a Flow's @router to a human, which the crew itself could not express cleanly.
Follow-up questions to expect
- "How do you know you have too many tasks?" — Handoffs losing facts, tasks that always pass together, and total latency growing faster than quality.
- "How do you run two tasks in parallel?" —
async_execution=Trueon both, then a later task withcontexton both to join them. - "Where do conditionals go?" — A Flow
@routerbetween crews, or aConditionalTaskinside a crew for a simple "skip this task if" rule.