Production systems

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

  1. Resolve the entity with a deterministic lookup.
  2. Pull three to eight chunks max.
  3. Ask Claude to answer or act only from those chunks or to abstain.
  4. 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