CrewAI Tools & Delegation
In CrewAI, agents are more than just clever prompt‑responders. Their real power comes from two mechanisms: Tools, which let them act on the outside world, and Delegation, which lets them hand off work to other specialised agents. This article is your implementation‑focused guide to both—how to design tools, how to wire them into agents, how delegation works inside a crew, and how to combine them to build robust, production‑ready multi‑agent systems.
What Are Tools in CrewAI
Tools are external capabilities that agents can invoke during task execution. Instead of relying solely on the knowledge encoded in their language model, agents can call tools to fetch live data, interact with APIs, read files, run calculations, or trigger side effects.
A tool is simply a Python function decorated with @tool (from crewai or crewai_tools). The decorator provides a name, a description, and automatically generates the JSON schema that the LLM needs to decide when and how to call it.
Examples of tools:
- Web search (Serper, Tavily)
- Database queries (SQL, vector search)
- REST API wrappers (GitHub, Slack, Stripe)
- File system operations (read/write files)
- Custom business logic (calculation, validation)
Once attached to an agent, tools become part of the agent’s thinking process. The agent can choose to call them, reason about their outputs, and incorporate the results into its final task output.
Why Tools Matter
Tools transform an agent from a passive knowledge source into an active participant in a workflow.
- Extend agent capabilities – Access real‑time data, perform calculations, or execute actions that the LLM cannot do on its own.
- Connect to external systems – Integrate with CRM, ERP, databases, and third‑party APIs without writing complex middleware.
- Improve accuracy and grounding – Ground responses in live, verifiable information rather than model‑internal knowledge.
- Automate real‑world actions – Send emails, create tickets, write to databases, trigger deployments.
- Keep agents focused – Offload deterministic or data‑intensive work to tools so the LLM can focus on reasoning and synthesis.
A research agent without a search tool can only guess. With a search tool, it can provide current, sourced information.
How Tool Usage Works in CrewAI
When an agent receives a task, it enters a reasoning loop that may involve tool calls. The flow is:
User Request → Agent receives task → Agent reasons → Agent calls tool(s) → Tool executes → Result injected → Agent continues reasoning → Task output
Under the hood, CrewAI binds the tool’s schema (name, description, parameters) into the LLM’s function‑calling interface. The LLM decides if a tool is needed and what arguments to pass. The framework then executes the tool, captures its output, and feeds it back to the LLM as an observation. This cycle repeats until the agent produces a final answer.
This is CrewAI’s built‑in “agent loop”. You don’t write a loop yourself—the agent instance manages it.
Types of Tools
CrewAI supports several tool categories, all of which can be mixed in a single agent.
1. Built‑in Tools
CrewAI ships with crewai_tools, a library of pre‑built, optimised tools. Examples:
SerperDevTool– web search via Serper.devScrapeWebsiteTool– scrape a webpageFileReadTool,FileWriteTool– local file operationsPDFSearchTool,DOCXSearchTool– document searchCodeInterpreterTool– execute Python code in a sandbox
These tools require minimal configuration; often just an API key.
from crewai_tools import SerperDevTool
search_tool = SerperDevTool(api_key="...")
2. Custom Tools
Any Python function can become a tool with the @tool decorator.
from crewai import tool
@tool("fetch_stock_price")
def fetch_stock_price(ticker: str) -> str:
"""Fetch the current stock price for a given ticker symbol."""
# Call a financial API
return f"Price of {ticker}: $150.25"
The docstring becomes the tool’s description, which is crucial for the LLM to understand when to use it.
3. API‑based Tools
Wrap any external REST or GraphQL API. Use requests or a client library inside the function.
@tool("get_weather")
def get_weather(city: str) -> str:
"""Return current weather for a city."""
response = requests.get(f"https://api.weather.com/v1/current?city={city}")
return response.json()["condition"]["text"]
4. Python Function Tools
For logic that doesn’t involve I/O, like calculations or data transformations.
@tool("calculate_loan_payment")
def calculate_loan_payment(principal: float, rate: float, months: int) -> str:
"""Calculate monthly loan payment."""
payment = principal * (rate * (1 + rate)**months) / ((1 + rate)**months - 1)
return f"${payment:.2f}"
5. External Service Tools via MCP
CrewAI can also connect to MCP (Model Context Protocol) servers, treating them as tool providers. This allows agents to use tools that are implemented in other languages, run in separate processes, or managed centrally. See the MCP Guide for details.
Tool Design Principles
Well‑designed tools make agents reliable and predictable.
- Atomic – Each tool does exactly one thing.
fetch_orderis better thanfetch_and_update_order. - Stateless – Tools should not rely on previous invocations. If state is needed, store it in the agent’s context (task output) and pass it in explicitly.
- Typed inputs/outputs – Use type hints and Pydantic models to define strict schemas. This helps the LLM generate correct arguments.
- Safe execution – Never expose dangerous operations directly. Validate inputs, use parameterised queries for databases, and restrict file system access.
- Deterministic behavior – The same inputs should produce the same outputs (as much as possible). Avoid randomness unless it’s a feature (and documented).
Example of a typed tool using Pydantic:
from pydantic import BaseModel, Field
class WeatherInput(BaseModel):
city: str = Field(description="City name")
country: str = Field(default="US", description="Country code")
@tool(args_schema=WeatherInput)
def get_weather(city: str, country: str = "US") -> str:
"""Fetch weather for a given city and country."""
# ...
Tool Execution Lifecycle
Every tool call follows a precise lifecycle inside an agent.
- Agent reasoning – The LLM evaluates the task, the agent’s role, and available tools.
- Tool selection – The LLM decides which tool (if any) can help complete the task.
- Argument generation – The LLM creates a JSON object matching the tool’s parameter schema.
- Tool invocation – CrewAI executes the function, passing the generated arguments.
- Result processing – The raw output (string or dict) is returned to the LLM as an “observation”.
- Output generation – The agent may call more tools or produce a final answer, all of which becomes the task output.
This loop is repeated until the agent is confident or hits the max_iter limit.
Delegation in CrewAI
Delegation is the mechanism by which one agent hands a piece of work to another agent within the same crew. It is the foundation of role‑based collaboration.
Instead of a single agent doing everything, you break the workflow into specialised tasks, each assigned to the agent best suited for it. The output of one task becomes the input of the next, effectively delegating the work downstream. In the hierarchical process, a manager agent explicitly allocates tasks to workers, and can even reassign them.
Delegation in CrewAI is not a method call from one agent to another; it’s the crew’s task graph that governs who does what and in what order.
Why Delegation Matters
- Role separation – Each agent focuses on its core competency (research, writing, editing, coding).
- Task specialization – Specialised agents with tailored tools and backstories produce higher‑quality outputs.
- Better scalability – Complex workflows can be composed from reusable agent roles.
- Improved output quality – A dedicated reviewer agent can catch errors that a generalist might miss.
Delegation turns a messy monolith into a clean pipeline of expert workers.
How Delegation Works
CrewAI offers two primary delegation patterns:
1. Sequential Delegation via Task Context
In a sequential crew, tasks are assigned to specific agents. When task B lists task A in its context, CrewAI automatically passes A’s output to B’s agent. This is delegation by data flow.
2. Hierarchical Delegation via Manager Agent
With Process.hierarchical, a manager agent is created. It reads the list of tasks, picks an agent that can handle each one, and dispatches them. The manager can also verify results and re‑delegate if something goes wrong.
Delegation can be automatic (the crew decides) or explicit (you hard‑wire the task‑agent mapping). In both cases, the developer controls the delegation structure.
Types of Delegation
| Type | Description | When to use |
|---|---|---|
| Direct Delegation | A fixed task assigned to a specific agent (task → agent) | Well‑defined pipelines where you know exactly who does what |
| Hierarchical Delegation | A manager agent dynamically assigns tasks to workers based on roles and current context | Dynamic workflows where the best agent might vary, or when quality checks are needed |
| Conditional Delegation | An agent (or manager) decides to delegate only if certain conditions are met | Complex logic, e.g., “if the confidence is low, escalate to a senior agent” |
| Multi‑step Delegation Chains | Several delegation steps in sequence (Agent A → Agent B → Agent C) | Long pipelines (e.g., data extraction → analysis → report writing) |
Tool Usage vs Delegation
These mechanisms are complementary, not interchangeable.
| Concept | Tool Usage | Delegation |
|---|---|---|
| Target | External system (API, DB, function) | Another agent within the crew |
| Execution | Immediate function call | Task assignment and context passing |
| Scope | Narrow, deterministic action | Broader reasoning and synthesis |
| Interaction | Agent → Tool → Agent | Agent A → Agent B (via task outputs) |
| Purpose | Extend capabilities, fetch/action data | Distribute work, specialise roles |
A good rule of thumb: Tools help an agent do its job; Delegation splits the overall job among different specialists.
Delegation Strategies
When building a crew, choose a delegation strategy based on the workflow’s needs.
- Role‑based delegation – Assign tasks based on agent roles (e.g., all “data gathering” tasks go to the
Researcher). The simplest and most transparent. - Skill‑based delegation – Agents have capabilities (tools, domain knowledge); tasks are routed to the agent whose skills match best.
- Load‑based delegation – In systems with multiple instances of the same role, you could distribute tasks to balance load (CrewAI does not natively support this out‑of‑the‑box, but you can implement it by spawning multiple agents of the same type and letting the manager choose).
- Context‑based delegation – The decision to delegate depends on the state; for example, an agent might decide to call another agent only when it needs a second opinion.
In practice, role‑based delegation (explicit task‑agent mapping) is the most common and easiest to reason about.
Error Handling in Tools & Delegation
Failures are inevitable. CrewAI gives you several levers for resilience.
Tool Failures
- Catch exceptions inside the tool – Return a descriptive error string rather than letting the exception propagate. The LLM can then self‑correct or ask for help.
- Retry logic – Use a library like
tenacitywithin the tool function to automatically retry transient errors. - Graceful degradation – If a non‑critical tool fails, the agent can skip it and continue with partial information.
@tool("safe_search")
def safe_search(query: str) -> str:
try:
return web_search(query)
except Exception as e:
return f"Search failed: {e}"
Delegation Failures
- Manager reassignment – In hierarchical mode, if an agent returns a poor output, the manager can ask it to redo or send the task to another agent.
- Fallback tasks – Design a task that runs only if the previous one fails (e.g., a simplified version of the task).
- Human intervention – Use
human_input=Trueon a task to pause for human review when delegation results are uncertain.
Retry Mechanisms
For delegation, the crew doesn’t automatically retry failed tasks. You can implement a loop by adding a conditional task that re‑runs a failed task, or by using the hierarchical manager’s natural retry logic.
State and Context Passing
- Tools return a string (or a serialisable object) that is injected into the agent’s memory as an observation. The agent can reference it in later reasoning.
- Delegation passes the entire output of a task to the next task’s agent. The
contextparameter in a task causes CrewAI to prepend that output as part of the agent’s instructions. You can also store intermediate results in a shared state if you use a custom crew base.
The flow of context is automatic and transparent, but you should carefully define expected_output to ensure the downstream agent receives structured, usable data.
Security Considerations
- Tool permissions – Only attach tools that the agent and its role truly need. Avoid giving a writer agent the ability to delete database records.
- Safe execution boundaries – Run code‑execution tools inside sandboxes (CrewAI’s
CodeInterpreterTooldoes this by default). Never allow arbitrary command execution on the host. - Input validation – Use Pydantic schemas to validate all tool arguments. Sanitise inputs before passing them to external APIs.
- External API security – Keep API keys in environment variables, never hard‑coded. Use the least‑privilege principle for service accounts.
Delegation is inherently safer than tool usage in terms of side effects, because an agent cannot directly cause an external action without calling a tool. But delegation can expose sensitive information; ensure that task outputs don’t leak PII to unintended agents.
Common Beginner Mistakes
- Overusing tools instead of delegating – A single agent with 10 tools becomes a “jack of all trades, master of none”. Split responsibilities and delegate.
- Over‑delegating simple tasks – Creating a separate agent for a trivial calculation adds overhead. Use tools for simple deterministic actions.
- Poor tool descriptions – The LLM relies on the docstring to know when to call the tool. Vague descriptions lead to misuse.
- Missing input validation – Without strict schemas, the LLM may pass malformed data that crashes the tool.
- Mixing responsibilities – An agent that both researches and writes may produce biased or inconsistent output. Delegate to dedicated roles.
- Ignoring error handling – An unhandled exception in a tool can derail the entire crew.
- Unbounded delegation chains – Too many delegation steps increase latency and complexity. Keep chains as short as possible.
Best Practices
- Keep tools atomic and reusable – One function, one clear purpose. Reuse the same tool across multiple agents.
- Delegate based on clear roles – Define roles with distinct goals; tasks should align perfectly with those goals.
- Validate all tool inputs – Use
args_schemawith Pydantic to enforce correct parameters. - Avoid unnecessary delegation chains – If one agent can do the work, don’t split it into three.
- Log all tool executions – Capture tool name, arguments (sanitised), result, and duration. Essential for debugging.
- Define strict output formats – Use
expected_outputas a contract. A writer agent should know it will receive a structured list, not a raw paragraph. - Test tools and delegation separately – Verify tool behavior in isolation, then test the full crew.
- Prefer sequential delegation for linear pipelines; use hierarchical when you need dynamic decision‑making or quality control.
Practical Example: Content Generation Crew with Tools & Delegation
We’ll build a crew that researches a topic (using a web search tool), delegates the findings to a writer, and then delegates the draft to an editor.
1. Define the tools
from crewai_tools import SerperDevTool
search_tool = SerperDevTool() # built-in web search tool
2. Define the agents
from crewai import Agent
researcher = Agent(
role="Research Specialist",
goal="Find and summarise the latest information on a given topic",
backstory="You are an investigative journalist. You always cross‑check facts.",
tools=[search_tool],
verbose=True
)
writer = Agent(
role="Content Writer",
goal="Create engaging blog posts from research data",
backstory="You are a senior copywriter who turns dry facts into compelling stories.",
verbose=True
)
editor = Agent(
role="Senior Editor",
goal="Polish content for accuracy, tone, and grammar",
backstory="You have an eagle eye for errors and a passion for clarity.",
verbose=True
)
3. Define the tasks
The researcher task will use the search tool. The writer task will receive the research output as context, and the editor task will receive the draft.
from crewai import Task
research_task = Task(
description="Research the topic: 'The rise of multi-agent AI systems in 2026'. "
"Find at least 5 key trends and write a concise summary for each.",
expected_output="A bullet list of 5 trends with 2‑3 sentence explanations.",
agent=researcher
)
writing_task = Task(
description="Using the research findings, write a 500‑word blog post. "
"Make it engaging and suitable for a technical audience.",
expected_output="A complete markdown article with title, intro, body, and conclusion.",
agent=writer,
context=[research_task] # delegation: researcher's output flows to writer
)
review_task = Task(
description="Edit the blog post for factual accuracy, readability, and grammar. "
"Return the final version ready for publication.",
expected_output="The polished markdown article.",
agent=editor,
context=[writing_task] # delegation: writer's output flows to editor
)
4. Assemble the crew
from crewai import Crew, Process
crew = Crew(
agents=[researcher, writer, editor],
tasks=[research_task, writing_task, review_task],
process=Process.sequential,
verbose=True
)
result = crew.kickoff()
print(result)
What happens step‑by‑step:
- The researcher receives the task. It uses the
SerperDevToolto perform web searches, retrieves articles, and compiles a bullet list.- Tool usage:
search_toolis called possibly multiple times.
- Tool usage:
- The researcher’s output (the bullet list) is automatically passed as context to the writer.
- Delegation: the work of transforming research into prose is delegated to the writer.
- The writer produces a draft article.
- The draft is passed as context to the editor.
- Delegation: the final polishing is delegated to the editor.
- The editor returns the finished article, which is the crew’s final output.
Throughout, the crew manages all context passing and delegation. The tools and agents are cleanly separated, making the system easy to extend or debug.
CrewAI Tools & Delegation in Real Systems
These patterns appear in virtually every production multi‑agent system:
- Automation Pipelines – A triage agent uses a database tool to look up customer info, then delegates to a specialist agent for handling refunds.
- Research Workflows – A data‑gathering agent uses scraping and search tools, then delegates to an analyst, who delegates to a reporter.
- Content Systems – SEO keyword tool used by a strategist agent, then delegated to writers and editors.
- Data Processing Systems – Extraction tools feed raw data to a cleaning agent, which delegates to an aggregation agent.
In all cases, tools provide actionable capabilities and delegation provides role‑based collaboration.
FAQ
1. What are tools in CrewAI?
Tools are external functions (APIs, Python code, databases) that an agent can call to perform actions beyond pure LLM reasoning.
2. How does delegation work in CrewAI?
Delegation is the assignment of a task to a specific agent. In a crew, tasks are linked via context, so the output of one task feeds into the next, effectively delegating work from one agent to another. In hierarchical mode, a manager agent dynamically delegates tasks.
3. Can agents delegate to multiple agents?
Yes. By creating multiple downstream tasks that use the same context, you can fan‑out delegation. Or use a hierarchical manager that assigns tasks to several agents.
4. What is the difference between tools and delegation?
Tools extend an agent’s capabilities (fetch data, execute code), while delegation splits the overall job among different agents based on their roles.
5. Can tools call other tools?
Not directly. The agent decides to call one tool, receives the output, then may decide to call another tool. Chaining happens through the agent’s reasoning loop.
6. How is context passed between agents in delegation?
Via the task’s context parameter. CrewAI automatically prepends the output of the referenced task(s) to the agent’s prompt for the current task.
7. Is delegation automatic or manual?
It depends on the process. In sequential mode, you manually set context—so delegation is explicit. In hierarchical mode, the manager automatically delegates based on role and task descriptions.
8. Can an agent refuse a delegation?
In hierarchical mode, the manager can re‑assign tasks if the first agent fails. In sequential mode, if an agent cannot complete a task, it will either error out or produce a best‑effort output; handling that is up to the developer.
9. How many tools should an agent have?
As few as necessary. Typically 1‑3 well‑defined tools. Too many tools confuse the LLM and increase the chance of incorrect usage.
10. How do I handle a tool that returns a large amount of data?
Return a summary or a reference (e.g., a URL, a file path) rather than the full payload. The agent can then use a separate tool to fetch specific details if needed.
11. Can I use LangChain tools with CrewAI?
Yes. CrewAI is compatible with tools that follow the LangChain tool interface.
12. How does memory affect delegation?
Agent memory (when memory=True is set) allows an agent to remember context across multiple tasks. This can enhance delegation, as the agent can recall earlier decisions without having to re‑parse the full context.
13. Are tools executed in parallel?
CrewAI does not run tool calls in parallel out of the box; the agent handles them sequentially. For parallel tool execution, you can design a custom agent that calls tools concurrently (advanced).
14. How do I debug tool calls?
Set verbose=True on the agent. The logs will show the LLM’s reasoning, the tool call request, arguments, and the returned result.
15. Can I use MCP tools in CrewAI?
Yes. You can connect to MCP servers and load tools from them. They behave identically to any other tool. See the MCP Guide.
16. What’s the best way to test delegation logic?
Test each task individually with its agent. Then test the full crew. Mock external tools to avoid side effects during tests.
Conclusion
CrewAI’s tool and delegation mechanisms give you a complete toolkit for building multi‑agent applications that are both capable and organised. Tools let agents interact with the world; delegation keeps the work distributed among specialists. When combined, they enable complex, reliable workflows that would otherwise require significant custom orchestration.
Key takeaways:
- Tools are atomic, external functions that extend an agent’s reach.
- Delegation is the structured passing of work between agents via tasks.
- Tool design should be atomic, safe, and well‑typed.
- Delegation strategies range from explicit sequential pipelines to dynamic manager‑driven assignment.
- Error handling, input validation, and security are essential for production use.
Now that you’ve mastered tools and delegation, deepen your expertise with:
- CrewAI Core Concepts – the fundamentals of agents, tasks, and crews.
- Taking CrewAI to Production – observability, caching, error recovery, and deployment.
For cross‑framework perspectives, explore the LangGraph comparison and the full framework comparison guide. To learn more about tool ecosystems, read the MCP Guide.
Start assembling your crew today—equip them with sharp tools and let them delegate like a world‑class team.