n. / Prompts and context
Definition
Context engineering is deciding what information goes into the model's context at each step of an agent: instructions, tools, retrieved facts, memory and past results. The aim is the smallest set that lets the model do the step well.
In more detail
In an agent, the context changes on every loop. Too little leaves the model guessing; too much costs money, slows each call and buries the useful part. Typical techniques are trimming old tool results, summarizing history, and retrieving only what the current step needs. Traces show exactly what was in context when a step went wrong.
Example
After ten steps an agent's history is 40,000 tokens. You keep the last three tool results in full, replace the older ones with a short summary, and quality stays the same at a third of the cost.
