CrewAI Multi-Agents

Course Content

CrewAI Multi-Agents

9 sections · 53 lessons

How do agents in CrewAI use tools?


What you need to know

Four ways to get tools

  • Ready-made: pip install 'crewai[tools]' gives crewai_tools with tools such as SerperDevTool (web search), ScrapeWebsiteTool, FileReadTool and many more.
  • Your own function: the @tool decorator — the docstring becomes the description, the type hints the schema.
  • Your own class: subclass BaseTool with an args_schema, for anything needing configuration, clients or retries.
  • MCP servers: agents can load tools from Model Context Protocol servers through the mcps field.
Python
from crewai import Agent, Taskfrom crewai.tools import toolfrom crewai_tools import SerperDevTool@tool("Company headcount")def company_headcount(domain: str) -> str:    """Return the latest employee count for a company website domain,    for example 'acme.com'. Use this before scoring company size."""    return lookup_headcount(domain)   # your data providerresearcher = Agent(role="Account Researcher", goal="...", backstory="...",                   tools=[SerperDevTool(), company_headcount], max_iter=8)score = Task(description="...", expected_output="...", agent=researcher,             tools=[company_headcount])   # only this tool for this task

lookup_headcount stands for your own provider client. If a task sets tools, they replace the agent's tools for that task.

The loop, one call at a time

  1. The model sees the task and the list of tool names, descriptions and argument schemas.
  2. It returns a tool call, for example company_headcount(domain="acme.com").
  3. CrewAI validates the arguments against the schema and runs the tool.
  4. The result goes back to the model as an observation, and the loop continues.

Useful tool options

  • result_as_answer=True — the tool's output becomes the task's final answer directly (good for tools that already produce the finished artefact).
  • max_usage_count=N — the tool can be used at most N times.
  • cache_function — decide which results the crew cache may store.

Why descriptions decide everything

The model never sees your code. It chooses a tool from its name and description alone. "Searches the web" is weak. "Searches recent news; use for events after 2024; returns 5 results with title, URL and snippet" tells the model when to use it and what comes back.

A real-life example

A B2B SaaS lead-qualification crew gave its researcher three tools: web search, a scraper and a headcount lookup. Traces showed the agent guessing company size from LinkedIn snippets found through web search in 40% of runs, and never calling the headcount tool.

The headcount tool's description was "Gets company data". The team rewrote it as in the example above — what it returns, what input format it takes, and when to use it. Headcount-tool usage rose to 95% of runs, and size errors in lead scores (compared with the sales team's manual checks on 60 leads) fell from 14 to 3. No model change, no prompt change — only the tool description.

Follow-up questions to expect

  • "What happens if the model passes bad arguments?" — CrewAI validates them against the schema and returns the error to the model, which usually corrects the call on the next step.
  • "Can a tool be async?" — Yes; BaseTool supports an _arun method, and async Flows and akickoff use native async.
  • "How many tools should an agent have?" — As few as the job needs; accuracy of tool choice drops as the list grows. Split tools across agents or tasks rather than giving one agent twenty.