Course Content
CrewAI Multi-Agents
9 sections · 53 lessons
What is an Agent in CrewAI, and what responsibilities does it have?
What you need to know
What an agent is made of
Python
1from crewai import Agent, LLM23analyst = Agent(4 role="Credit Document Analyst",5 goal="Extract income and obligations from loan documents accurately",6 backstory="You worked 10 years in retail lending. "7 "You never state a number without the page it came from.",8 tools=[pdf_reader], # your own PDF-reading tool9 llm=LLM(model="openai/gpt-4o-mini", temperature=0.1),10 max_iter=10, # default is 2511 allow_delegation=False, # default is False12 verbose=True,13)role,goal,backstory— the persona; CrewAI puts them into the system prompt.tools— what it can actually do in the world.llm— which model runs its loop; different agents can use different models.max_iter,max_execution_time,max_rpm— limits on loop steps, wall-clock seconds and requests per minute.
What happens when an agent runs a task
- CrewAI builds a prompt from the agent's persona, the task's
descriptionandexpected_output, any context from earlier tasks, and the tool descriptions. - The model either calls a tool or gives a final answer.
- Tool results are added to the conversation and the loop continues.
- If it reaches
max_iter, CrewAI makes one last call asking for its best final answer.
Responsibilities: agent vs the rest
| Belongs to the agent | Belongs elsewhere |
|---|---|
| Understanding the instruction | The order of work (Crew, Process, Flow) |
| Choosing and calling tools | Which outputs it sees (Task.context) |
| Staying inside its role | Checking the output (output_pydantic, guardrails) |
| Producing the deliverable | Retries after a failed check (the task) |
An agent can also run without a crew: analyst.kickoff("Summarise this payslip: ...") runs one standalone loop, which is useful for chat-style features or inside a Flow step.
A real-life example
A loan-document review crew at an NBFC has three agents:
- Document Analyst — tools: a PDF reader and an OCR tool. Job: pull out monthly salary, employer, existing EMIs and bank balance, with page numbers.
- Policy Checker — no tools, the lending policy loaded as knowledge. Job: compare the numbers with policy (for example, total EMIs must stay under 50% of income).
- Summary Writer — no tools. Job: a one-page note for the credit officer.
In an early version the analyst's backstory said "then check the policy and write a summary". The analyst kept doing all three jobs badly. Moving those steps out of the backstory and into separate tasks made the analyst's output clean: 12 fields with page references, every time. The lesson: an agent describes who, a task describes what to do now.
Follow-up questions to expect
- "Can one agent run several tasks?" — Yes. An agent is reusable; for example, a researcher can own both the company research task and the competitor research task.
- "What happens when
max_iterruns out?" — The agent is asked once more for its best final answer, so you get an answer, possibly a weak one. Guardrails should catch it. - "Can agents use different models?" — Yes, and you should: a strong model for reasoning or managing, a cheaper one for extraction or formatting.