Context engineering is the practice of controlling what is in an agent’s context window at each step: system prompt, tool definitions, conversation history and tool results. The window is finite, and models use information less well as it fills with noise. Managing context is arguably the most important skill in building agents.

Techniques

  • Load on demand. Give the agent search and read tools rather than pre-loading documents. This is how coding agents work in codebases far larger than their window.
  • Keep tool output lean. Summarise, paginate and truncate. A 50,000-line log dump wastes context.
  • Compact long sessions. Near the limit, replace the history with a summary that keeps decisions and open threads.
  • Write things down. Notes in files (plans, progress logs, to-do lists) let an agent recover its state after a reset or compaction.
  • Delegate. Subagents do context-heavy work in a fresh window and return only a summary.

In multi-agent systems the same principles apply per agent: isolate each agent’s context, persist what later steps need, and compress large data before passing it on (Google Cloud).

Agent loop

Sources