CrewAI Multi-Agents

Course Content

CrewAI Multi-Agents

9 sections · 53 lessons

How does CrewAI simplify multi-agent orchestration compared to manual code?


What you need to know

Writing multi-agent code by hand means building these parts yourself:

  1. The agent loop — call the model, parse a tool call, run the tool, feed the result back, stop at a final answer or a limit.
  2. Tool plumbing — JSON schemas from Python types, argument validation, errors the model can read.
  3. Prompt assembly — persona, task, expected output, context, tool list, format rules.
  4. Output handling — parse into a schema, retry with feedback when it fails.
  5. Coordination — order of tasks, passing outputs, parallel tasks, delegation.
  6. Operations — token counts, logs, traces, replay after failure.

That is often several hundred lines of code before any business logic, and you maintain all of it.

What the CrewAI version looks like

Python
from crewai import Agent, Crew, Process, Taskfrom crewai.project import CrewBase, agent, crew, taskfrom crewai_tools import SerperDevTool@CrewBaseclass ResearchCrew:    agents_config = "config/agents.yaml"    tasks_config = "config/tasks.yaml"    @agent    def researcher(self) -> Agent:        return Agent(config=self.agents_config["researcher"],                     tools=[SerperDevTool()])    @agent    def writer(self) -> Agent:        return Agent(config=self.agents_config["writer"])    @task    def research(self) -> Task:        return Task(config=self.tasks_config["research"])    @task    def write_report(self) -> Task:        return Task(config=self.tasks_config["write_report"])    @crew    def crew(self) -> Crew:        return Crew(agents=self.agents, tasks=self.tasks,                    process=Process.sequential)

crewai create crew research scaffolds this layout. The decorators collect agents and tasks in declaration order; the YAML files hold the role, goal, backstory, descriptions and expected outputs.

What you give up

  • Prompt control. The framework writes part of every prompt. Behaviour can shift after an upgrade.
  • Transparency. Debugging goes through traces of the framework's loop, not your own code.
  • Fit. If your workflow is mostly deterministic code with one LLM call, a framework adds weight for little gain.

It is a productivity and consistency gain, not new capability: anything CrewAI does, you could write yourself.

A real-life example

A startup built a daily news-digest pipeline by hand: 900 lines of Python for the agent loop, tool calling, retries, JSON parsing and logging. Every model change broke the tool-call parser, and only one engineer understood it.

They rewrote it as a CrewAI Flow with two small crews in about 250 lines plus YAML. Guardrails replaced their retry code, output_pydantic replaced the JSON parser, and tracing replaced their custom logs. The editor now adjusts the writer's tone in agents.yaml herself. The cost: after a CrewAI upgrade, section lengths grew about 15% because a default prompt changed. Their golden-set test caught it, and they pinned the version until they had adjusted expected_output.

Follow-up questions to expect

  • "When would you not use CrewAI?" — A single tool-using assistant, a mostly deterministic pipeline, or a workflow that needs step-level control and durability better served by LangGraph or plain code.
  • "Can you customise CrewAI's prompts?" — Yes, agents accept custom system, prompt and response templates, but then you own them across upgrades.
  • "Why YAML?" — It separates prompt text from code, so non-engineers can review and change it, and diffs are easy to read.