Context engineering and memory
Two hours into a task, a coding agent starts acting strangely. It re-reads files it already read. It forgets the instruction "do not touch the payments module" and edits the payments module. Nothing about the model changed. Its context did: it is now 90% old tool output, a few thousand lines of logs and file contents, with the original instructions buried somewhere near the top.
Prompting is about writing one good instruction. Context engineering, a name that caught on in 2025, is the bigger job: deciding what goes into the window on every single call of a long running system, and what stays out.
An agent has made 60 tool calls and its context is almost full. What would you remove first? What must never be removed?
Agents fill the window fast#
A chat grows by one short message per turn. An agent grows by whatever its tools return, and tools return a lot: a file is thousands of tokens, a search result page is thousands more, a stack trace is hundreds.
Long before the window is full, quality slips: the original instructions are far away, and most of the context is stale output the model still has to read on every call. This is why tools that return a short summary instead of a raw dump make an agent both cheaper and smarter.