Selective Context Inclusion
Send only the files, sections, or conversation turns relevant to the current query. Requires a retrieval or routing step to decide what to keep.
How It Works
Before constructing the prompt, a retrieval system ranks available content by relevance to the current task. Only the top-ranked items are included. Relevance can be determined by embedding similarity, keyword matching, or a learned ranker.
What to Select
- specific files or functions instead of the full repository
- relevant conversation turns instead of full history
- sections of a document instead of the whole text
- specific tool outputs instead of all available results
Trade-offs
- Pros: can achieve very high context reduction with high relevance.
- Cons: retrieval quality determines task success; poor selection drops critical context.
See Also
- Signal-per-Token Optimization — selective inclusion is a primary technique for maximizing signal density.
- Subagents as Context Firewalls — a parent constructing a child's brief performs selective inclusion on the child's behalf.
- Hierarchical Memory — semantic memory retrieval is a form of selective inclusion.
- Grep-Result Tool Output — selective inclusion applied to search results.
- Context Isolation via Subagents — narrows by relevance; isolation keeps the material out of the caller's context entirely.
- Progressive Disclosure — makes the inclusion decision structural: material is split into levels the model pulls in as needed.
Tools
- LangChain RetrievalQA — retrieves relevant documents before answering.
- RAGFlow — retrieval-augmented generation with selective document inclusion.