New Tool Radar

AI Agents & Automation

How to Attach a Knowledge Source to a CrewAI Agent

Attach a knowledge source to a CrewAI agent so it answers from your documents instead of general knowledge.

Schematic with three steps: Add the knowledge source to the agent; Check what the agent retrieves; Test a question outside the documents.

A CrewAI agent can carry knowledge sources: documents the agent retrieves from when it works, so its answers are grounded in your material. Knowledge only changes the prompt and adds retrieved context; unlike a tool, it gives the agent no new action. Attach the source to the agent that needs it, give the agent an embedder if the source needs one, and test with a question whose answer is only in your documents.

What you need

  • A CrewAI agent with a role, goal and backstory already defined
  • A document the agent should answer from
  • An embedder configured for the agent’s knowledge, or the framework default

Step 1: Add the knowledge source to the agent

Set the knowledge source on the agent, pointing at your document. The agent’s role name is also used as the knowledge collection name, so keep the role short and distinct.

Step 2: Check what the agent retrieves

Run the agent on a question from the document and confirm the retrieved chunks are the right passages. If the agent answers from general knowledge instead, the source is not attached or not being read.

Step 3: Test a question outside the documents

Ask a question the documents do not cover and confirm the agent says so, or marks the answer as ungrounded, instead of inventing a confident reply.

Worked example: synthetic knowledge check

The table below is a synthetic example. It shows the expected result of knowledge retrieval; no agent was run.

Question Retrieved from docs? Result
Policy question in the document Yes Pass
Procedure question in the document Yes Pass
Question outside the documents No Agent says so

Expected result (UNTESTED). the two document questions are answered from retrieved passages, and the third is flagged as ungrounded. This check was not run live; the table shows the expected result for the synthetic example.

Limits

  • Knowledge only changes the prompt and adds context; it does not give the agent a new action.
  • The agent recalls only a few memories and chunks per task, so a long document may not surface the passage you need.
  • Check the retrieved chunks, not just the final answer, because a confident answer can still come from general knowledge.

Sources

See all