Retrieval for Claude agents: hybrid search, not a bigger window
Long context does not replace retrieval. Production agents need a small, cited, testable set of chunks and a budget for what enters the prompt.
Retrieval is how a Claude agent gets the facts it was not trained on: tickets, policies, SKUs, the current account. Dumping a 200k-token dump into the window feels like retrieval. It is usually just an expensive way to confuse the model and the bill. See prompt caching and cost.
Production retrieval is hybrid when it needs to be: keyword for identifiers and exact policy clauses, embeddings for "something like this," and a reranker or rules so the prompt only sees a handful of chunks.
What to retrieve
- The current record the user is talking about
- The policy clauses that constrain the action
- Recent related events, capped
Do not retrieve "everything about the customer." That is how you leak PII into logs and how injection hides in a footnote. Mark retrieved text as untrusted, as in prompt injection defense.
Make retrieval testable
If you cannot name the chunk that justified a write, you cannot eval the system. Golden cases should include the expected sources, not just the expected prose. That is the same discipline as structured outputs: the downstream code needs a citation field it can assert on.
A default that works
- Resolve the entity with a deterministic lookup.
- Pull three to eight chunks max.
- Ask Claude to answer or act only from those chunks or to abstain.
- Log chunk ids with the trace.
Long context is useful for a document the user just uploaded. It is not a strategy for a knowledge base that changes daily. If retrieval is the hole in your agent, it will show up in an audit as "answers that sound right and cite nothing."
Related notes
Production systems
Claude Agent SDK Session Recovery: Resume, Fork, Compact, and Checkpoint Safely
Learn when to continue, resume, fork, compact, and checkpoint Claude Agent SDK sessions so long-running agents can recover safely.
Production systems
Why most Claude pilots never reach production
Most Claude pilots stall on integration, evaluation and cost, not prompting. Here is what actually blocks a production launch, and how to unblock it.
Production systems
MCP versus ad-hoc Claude tools: pick the contract, not the acronym
MCP is a protocol. The production question is whether Claude has a narrow, permissioned contract with your systems of record.