Sistava

What is Context Injection?

Also called Context Assembly, Prompt Augmentation.

Context injection is the practice of inserting relevant information into a model's prompt before it generates a response, such as retrieved passages, user profile facts, the current date, or tool schemas. Because the model only sees what the prompt contains, injection is how an application determines what the model knows for that call.

Every model call is assembled by the surrounding application, which chooses a system prompt, conversation history, retrieved documents, and any structured state. Injection refers to that assembly step. The choice of what to include, in what order, and with what labeling has a measurable effect on output quality and is a distinct engineering concern.

Placement and labeling matter. Injected material is usually delimited and attributed so the model can distinguish reference text from instructions and can cite its source. Position within the prompt also influences use, since models attend unevenly across a long context and material buried in the middle is more likely to be overlooked.

Injection has a security dimension. Text pulled from documents, web pages, emails, or tool results may contain instructions aimed at the model, and a system that injects it without marking it as untrusted data invites prompt injection attacks. Treating retrieved content as data rather than as commands is the standing mitigation.

Budgeting completes the picture. Context space is finite and shared between instructions, history, retrieved passages, and the answer itself, so injection policies rank candidates and drop the rest. Over injection is a common failure, since a prompt stuffed with loosely related material dilutes attention and raises both latency and cost.

Key points

In practice

Before answering a question about a customer's plan, an application injects four items: the system instructions, the last six conversation turns, two retrieved passages from the billing documentation, and a short profile block stating the account tier and renewal date. The model composes its answer from those pieces, and the passages are labeled so the reply can cite them.

Related terms

Back to the AI Glossary