DS DevShelfHub Projects · AI tools
Tutorials / CrewAI / Reference / Classes / PDFSearchTool
Class tools

PDFSearchTool: Reference Guide

By DevShelfHub

Semantic search within a PDF — agent supplies the query, tool returns top chunks.

See the CrewAI API reference index, CrewAI introduction, and core concepts for surrounding context.

What is PDFSearchTool?

PDFSearchTool packages a lightweight RAG loop around a single document: on first invocation it parses the PDF, chunks text, embeds those chunks, and answers subsequent agent queries with vector similarity search. That makes it ideal for one-off policy Q&A or contract review where wiring a full PDFKnowledgeSource pipeline would be heavy-handed.

Because indexing happens inside the tool, memory and startup time scale with file size — huge filings can blow container RAM or exceed serverless limits. Multi-document corpora belong on Agent knowledge_sources with persistent vector stores instead of per-call tool indexes.

Retrieval quality mirrors the underlying embeddings and chunking heuristics: scanned PDFs without OCR may yield empty indexes, and table-heavy pages may produce noisy chunks compared to CrewDoclingSource pipelines.

Mount the tool only on agents that truly need ad hoc PDF access; otherwise you duplicate embedding work already handled by crew-level knowledge_sources and pay twice for the same vectors.

When to Use

One-off Q&A over a small PDF.

Use Cases

  • Single-document Q&A
  • One-off policy lookup
  • Contract clause extraction

Key Features

  • RAG built-in
  • Per-PDF index on first query
  • Lightweight versus full knowledge pipelines

When NOT to Use

Large corpora — use a knowledge source.

Notes

Cold-start latency

First query pays parsing + embedding costs. Warm the tool during deploy or accept a slower first answer in demos.

Memory ceilings

Watch RSS in Kubernetes when agents mount many large PDFs concurrently. Prefer shared vector infrastructure for big documents.

Citation discipline

Ask the agent to quote chunk text verbatim when compliance matters; semantic similarity alone is not a notary service.

Import

python
from crewai_tools import PDFSearchTool

Key Parameters

Parameter Type Default Purpose
pdf str PDF path or URL.

Code Examples

Agent with policy lookup

python
from crewai import Agent
from crewai_tools import PDFSearchTool

agent = Agent(
    role='Policy bot',
    goal='Answer using the attached PDF only',
    backstory='If the PDF lacks the answer, say so explicitly.',
    tools=[PDFSearchTool(pdf='docs/refund_policy.pdf')],
    verbose=True,
)

Task-focused crew snippet

python
from crewai import Agent, Task, Crew, Process
from crewai_tools import PDFSearchTool

reader = Agent(
    role='Reader',
    goal='Extract clauses',
    backstory='You search the PDF tool before speculating.',
    tools=[PDFSearchTool(pdf='contracts/msa.pdf')],
)

t = Task(description='What is the liability cap?', expected_output='Quoted clause', agent=reader)
Crew(agents=[reader], tasks=[t], process=Process.sequential).kickoff()

When to migrate to PDFKnowledgeSource

python
# from crewai.knowledge.source.pdf_knowledge_source import PDFKnowledgeSource
# analyst = Agent(..., knowledge_sources=[PDFKnowledgeSource(file_path='large-corpus/*.pdf')])

Common Mistakes

❌ Pointing pdf= at a URL that requires cookies without configuring fetch

✅ Download to disk first or use an authenticated scraper tool upstream.

PDFSearchTool FAQ

What is PDFSearchTool in CrewAI?

Semantic search within a PDF — agent supplies the query, tool returns top chunks. PDFSearchTool packages a lightweight RAG loop around a single document: on first invocation it parses the PDF, chunks text, embeds those chunks, and answers subsequent agent queries with vector similarity search. That makes it ideal for one-off policy Q&A or contract review where wiring a full PDFKnowledgeSource pipeline would be heavy-handed. Because indexing happens inside the tool, memory and startup time scale with file size — huge filings can blow container RAM or excee…

Which package defines the CrewAI class PDFSearchTool?

DevShelfHub maps PDFSearchTool to Python module crewai_tools (package path crewai_tools in this reference). Pin your installed crewai version and match imports to the snippet on this page.

When should I use PDFSearchTool?

One-off Q&A over a small PDF.

When should I avoid using PDFSearchTool?

Large corpora — use a knowledge source.

How do I import PDFSearchTool in Python?

from crewai_tools import PDFSearchTool

Where can I explore more CrewAI API reference pages?

Open the CrewAI API reference index on DevShelfHub to search 58 classes, 30 methods, and 16 decorators, each with runnable examples, parameters, common mistakes, and cross-links.