Agent Tools in CrewAI
In CrewAI, tools are how agents take real actions: search the web, read files, query databases, run code, or even collaborate with other agents. You attach tools to an agent so it stops being “just a chat model” and becomes a capable worker in your workflow.
1. What Is a Tool?
A tool is a function or skill an agent can call when reasoning is not enough.
Examples:
- Web search (e.g., SerperDevTool, WebsiteSearchTool).
- File and directory access (FileReadTool, DirectoryReadTool).
- RAG over PDFs, CSVs, databases, etc.
- Code execution and data analysis (CodeInterpreterTool).
- Collaboration helpers (delegate work, ask coworker).
Key characteristics:
- Utility – Tools perform concrete actions (search, read, write, scrape, compute).
- Integration – Tools plug directly into agents via the tools=[...] parameter.
- Customizability – You can build your own tools for any API or internal system.
- Error handling – Tools are designed to fail gracefully.
- Caching – Tools can cache results to avoid repeated expensive calls.
- Async support – Tools can run asynchronously for non‑blocking IO.
2. Using Built‑In CrewAI Tools
Most common tools live in the crewai_tools package.[web:126][web:116]
2.1 Installation
2.2 Example: research + writing workflow
Here tools let:
- The researcher pull fresh web data.
- The writer read prior posts and save a new one to disk.
3. Common Tool Types (High‑Level)
CrewAI and crewai_tools include many ready‑made tools:
Search & Web / RAG
- SerperDevTool, WebsiteSearchTool, ScrapeWebsiteTool, ScrapeElementFromWebsiteTool, FirecrawlSearchTool, FirecrawlCrawlWebsiteTool.
- RAG over PDFs/CSVs/text: PDFSearchTool, CSVSearchTool, TXTSearchTool, JSONSearchTool, MDXSearchTool, DOCXSearchTool, DirectorySearchTool, RagTool.
- GitHub & DB: GithubSearchTool, PGSearchTool, XMLSearchTool.
Files & Directories
- DirectoryReadTool, FileReadTool.
Code & Data
- CodeInterpreterTool, CodeDocsSearchTool.
Media & Vision
- DALL-ETool / VisionTool for image generation.
YouTube & Video
- YoutubeChannelSearchTool, YoutubeVideoSearchTool.
Integration connectors
- ApifyActorsTool, ComposioTool, LlamaIndexTool, EXASearchTool, etc.
All are built with error handling + caching out of the box.
4. Creating Your Own Tools
You typically build custom tools when you need to talk to your APIs, databases, or services.
There are two main approaches:
4.1 Subclass BaseTool
Use this when you want full control and a clear input schema.
Attach it to an agent via tools=[MyCustomTool()].
4.2 Use the @tool decorator (sync)
Simplest way for quick tools.
The docstring is important: the agent reads it to decide when to use the tool.
5. Asynchronous Tools
Async tools allow non‑blocking operations (network, IO, etc.).
5.1 Async function with @tool
5.2 Async BaseTool implementation
Usage is the same; CrewAI handles sync vs async behind the scenes:
6. Tool Caching and cache_function
All tools in CrewAI support caching to avoid recomputing the same results.
- By default, caching is enabled for tools.
- You can define custom cache logic via cache_function on the tool.
Example: cache only even results.
Attach to an agent:
This pattern is helpful when:
- Some outputs are reusable (e.g., static data).
- Others should always be recomputed (e.g., time‑sensitive queries).
7. How Tools Fit the Agentic Architect Mindset
As an “Agentic Architect” Think about it this way:
- Agents = specialists with roles, goals, and backstories.
- Tools = their instruments and APIs (browser, DB, code runner, RAG, integrations).
- You design which tools each role gets, so the team as a whole has all necessary capabilities without over‑arming each agent.
A practical approach:
- Start with a reasoning‑only agent (no tools).
- Add one search tool and show the difference.
- Add file / RAG tools for knowledge.
- Add custom tools for company‑specific APIs.