Core Concepts
Reasoning
Memory & Retrieval
Agent Types
Design Patterns
Training & Alignment
Frameworks
Tools
Safety & Security
Evaluation
Meta
Core Concepts
Reasoning
Memory & Retrieval
Agent Types
Design Patterns
Training & Alignment
Frameworks
Tools
Safety & Security
Evaluation
Meta
Background context is supplementary information loaded into the context window to provide grounding knowledge. It includes retrieved documents, knowledge base entries, uploaded files, codebase contents, and any reference material the model needs to produce informed responses — without being the direct subject of the user's query. 1)
Within the context window, background context occupies the space between instructional context (which defines behavior) and operational context (which contains the active task). It provides the factual foundation the model draws upon when generating a response. 2)
Typical sources of background context:
Background context is injected into the prompt before the user's query, giving the model access to information beyond its pre-training data. The transformer's self-attention mechanism processes all tokens — background and operational — simultaneously, allowing the model to cross-reference grounding material with the task at hand. 3)
This mechanism is what makes grounding possible: the model can cite specific facts from loaded documents rather than relying solely on parametric knowledge, reducing hallucination. 4)
Effective management of background context is critical because it competes for token budget with all other context types:
Retrieval-Augmented Generation is the primary mechanism for populating background context. A RAG pipeline:
Larger context windows improve RAG by fitting more retrieved chunks, but they also raise the risk of attention dilution if too much irrelevant material is included. 6)
Models with million-token context windows can ingest entire documents natively, reducing the need for retrieval-based chunking. However, RAG remains valuable for:
The emerging best practice is hybrid context engineering: using RAG for dynamic retrieval combined with long context for stable reference material. 7)