Prompt Enrichment
Prompt enrichment adds user data, retrieved documents, tool results, or examples to a request before it reaches an AI model, so answers fit the user.
Prompt enrichment is the automatic addition of information to a user's request before it reaches an AI model. Application code sits between the user and the model and fills in what the user did not type: their account details, the documents that answer the question, live data from tools, worked examples, or a more detailed version of the request itself. A customer who asks "Why is my camera not detected anymore?" types seven words, and the large language model (LLM) receives those seven words plus the customer's device, software version, and the help article about that exact problem. The term is an umbrella for several techniques, of which retrieval-augmented generation (RAG) is the best known.
What Enrichment Adds#
- User and session data: Profile fields, plan, language, location, the current date, or the page the user is on, read from the application's own records.
- Retrieved knowledge: Passages found by searching a document collection or a knowledge graph for text related to the request.
- Tool results: Values fetched for this request, such as an order status from an API, a database row, or the output of another model.
- Selected examples: Few-shot examples chosen per request because they resemble the input, instead of one fixed set for every request.
- Rewritten queries: A model expands a terse request before it is used. In HyDE, Luyu Gao and colleagues have an LLM write a hypothetical answer, then use that document's embedding to retrieve real documents, which outperformed the same unsupervised retriever given only the question.
The following example enriches a support question with account data and the most relevant help article, retrieved by TF-IDF similarity with scikit-learn:
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.metrics.pairwise import cosine_similarity
# Context the user never typed: their account record and the help center's articles
account = {"plan": "Pro", "device": "USB webcam", "app_version": "2.3"}
articles = [
"Version 2.4 fixes USB webcams that are not detected after a system update.",
"Pro plans include ten concurrent video streams per workspace.",
"Invoices are available on the billing page as soon as a payment succeeds.",
]
question = "Why is my camera not detected anymore?"
# Retrieve the article most similar to the question
vectorizer = TfidfVectorizer().fit([*articles, question])
scores = cosine_similarity(vectorizer.transform([question]), vectorizer.transform(articles))[0]
best = articles[scores.argmax()]
# Assemble the enriched prompt the model actually receives
profile = ", ".join(f"{key}: {value}" for key, value in account.items())
prompt = f"Customer profile: {profile}\nRelevant article: {best}\nQuestion: {question}"
print(prompt)It prints:
Customer profile: plan: Pro, device: USB webcam, app_version: 2.3
Relevant article: Version 2.4 fixes USB webcams that are not detected after a system update.
Question: Why is my camera not detected anymore?The user's question never mentions a webcam, a version, or an update, yet the enriched prompt contains everything needed to answer "update from 2.3 to 2.4". Production systems usually retrieve with dense embeddings from a vector database or with hybrid search, but the assembly step is the same.
Enrichment in Practice#
In 2023, GitHub described how Copilot's neighboring tabs technique searches the files a developer has open for snippets similar to the code around the cursor and adds them to the prompt, which produced a 5% relative increase in how often users accepted Copilot's suggestions. Chatbots for customer support enrich every turn with account and order records, and AI agents enrich each step with the results of their previous tool calls.
Vision pipelines enrich prompts with what a detector found. In Ultralytics Platform Agents, an LLM block sends the selected vision-language model each image together with the results of the blocks upstream of it, such as YOLO26 detections, so a prompt written once is enriched with fresh object detection results for every image the workflow processes.
Enrichment has costs. Every added passage uses tokens, which raises price and inference latency, and irrelevant or excessive context lowers accuracy, the effect known as context rot. Retrieved web pages and documents can also carry prompt injection attacks, and any personal data added to a prompt raises data privacy concerns, since it is sent to whoever runs the model.
Prompt Enrichment vs. Related Terms#
- Retrieval-augmented generation (RAG): The form of enrichment that searches an external document collection. Enrichment also covers data that needs no search, such as a user's plan or the current date.
- Prompt engineering: A person designs the prompt template. Enrichment fills that template with request-specific data at runtime.
- Context engineering: Manages everything in a model's context across an application, including what to add, compress, or drop at each step. Enrichment is the adding part.
- Grounding: Tying a model's output to verifiable sources. Enrichment supplies those sources in the prompt.
- Prompt compression: Shortens a prompt by removing low-information tokens, and is often applied after enrichment when the added context is long.










