- Home
- Resources
- Integrations
- Contextual Compression Retriever
n8n Contextual Compression Retriever nodeConfigure Contextual Compression Retriever in n8n.
A retriever hands documents to a chain, and this one hands over less of them. The n8n Contextual Compression Retriever node sits between another retriever and the node that reads its output, with a chat model that keeps only the passages tied to the question. Two ports to connect, no settings to fill in.
Verified Trustpilot reviews · AI, automation & growth agency
What does the n8n Contextual Compression Retriever node do?
It wraps another retriever, a sub-node that looks up documents for a question, and filters what that retriever returns. Every document coming back goes through a chat model, the sub-node that talks to a provider like OpenAI or Anthropic, and only the part that actually answers the question stays. The chain downstream gets the same documents, shorter.
Similarity search is generous. Ask a vector store for the top matches and it returns whole chunks, question-related sentences buried inside pages of surrounding text. That text still travels to the model that writes the answer, still counts against its context window, the amount of text a model can read in one call, and still gives it room to answer beside the point. Compression is the step that cleans this up.
Take a support knowledge base indexed in a vector store. A customer asks about a refund deadline, the retriever brings back 4 chunks of a general terms page, and only two sentences of those chunks mention the deadline. Plug the Contextual Compression Retriever between the store retriever and the AI Agent or the question and answer chain, and those two sentences are what the answer is built on.
Second case, an internal documentation assistant reading long meeting notes. Raw retrieval gives full pages, so the answer drifts into whatever else was discussed that day. With compression, the model that writes the answer sees only the lines about the topic asked. Third case, a pipeline where retrieval costs add up: each call to the compression model is billed by that provider, whether you run OpenAI, Anthropic or Google Gemini, and you trade those calls against a shorter prompt in the final one.
When to skip it. If your chunks are already small and precise, plug the vector store retriever straight into the chain and save a model call per document. If the problem is that the right document never comes back at all, the answer is upstream: better chunking, or the MultiQuery Retriever, which rewrites the question several ways before searching. Compression improves what you found, it does not find more.
Two limits worth knowing before you wire it. Compression reads each returned document with a chat model, so retrieval takes longer and depends on that provider staying up. And it can cut too much: a fact the chain needed, sitting in a sentence the compression model judged unrelated, is simply gone by the time the answer is written. Test on real questions before shipping. The broader n8n picture, hosting and pricing model included, is in the n8n review.
What do you plug into it?
This is a sub-node: it never runs on its own, it attaches to the port of a root node and works when that node runs. It has its own ports too, and both of them are required.
Ports (what plugs in)
- Chat Model
ai_languageModelrequired - Retriever
ai_retrieverrequired
Output (what it plugs into)
- Retriever
ai_retriever
01Chat Model
The model that reads each retrieved document and rewrites it down to the part related to the question. This is the port that does the compression work.
Key parameters
- Required: leave it empty and the node refuses to run.
- OpenAI Chat Model or Anthropic Chat Model: the usual starting points, each carrying the credential of its provider.
- Ollama Chat Model: for documents you would rather not send outside your own machines.
- Model Selector: to route between several models instead of hard-wiring one.
02Retriever
The retriever whose output gets compressed. This node does not search anything by itself, it filters what the retriever below it brings back.
Key parameters
- Required: without a retriever plugged in, there is nothing to compress.
- Vector Store Retriever: the common choice. It reads a vector store you filled beforehand, and it is where most setups start.
- Workflow Retriever: documents from another n8n workflow, not a store.
- MultiQuery Retriever: when one question should be searched several ways before compression.
Contextual Compression Retriever
The Contextual Compression Retriever node has 0 parameters. For each one: the node as you configure it in n8n, what the parameter changes, and our field notes.
Parameters index
Need help automating Contextual Compression Retriever with n8n?
A person reads every message.
Questions people ask next
01Is the Contextual Compression Retriever included in n8n?
02What do you need to make it work?
03What are the limits of the n8n Contextual Compression Retriever node?
04What is the minimum to connect, and which sub-node should you start with?
05n8n or Make for this kind of retrieval?
Get our weekly integration tips.
No spam. Unsubscribe anytime.


