AI builder glossary
Context engineering
Deciding and assembling everything a model sees on each call, from instructions and history to retrieved data and tool results, within a token budget.
Context engineering widens the lens from the wording of a prompt to the whole input. On any real request, the instructions are a small part of what the model reads; the rest is conversation history, user and account details, retrieved documents, tool definitions, and earlier tool results. Choosing, ordering, and trimming that material is often what separates a feature that works from one that doesn't.
In code, it usually looks like a context assembly step that runs before every model call. It gathers candidate pieces, ranks them by how much they matter for this task, fits them into a token budget, and lays them out in a consistent order with clear labels. Lower-priority material, such as old turns or marginal search results, is summarized or dropped first.
The common failure is assuming more context is safer. Extra material costs money on every call, slows responses, and can pull the model toward irrelevant details or stale facts. The opposite failure is just as real: the model can't use what it wasn't given, so a missing account plan or policy page produces a confident wrong answer.
Test context the way you test prompts: log exactly what was sent, and check failures against it before blaming the model.
Before drafting a reply, a help-desk app assembles the ticket, the customer's plan and recent orders, the three most relevant help articles, and a summary of earlier tickets, dropping the older-ticket summary first if the budget is tight.
Learn more in the course
Related terms
Go from definitions to doing
Learn to build AI-powered apps in 132 practical lessons.