Overview
An agent can only reason over the information that is available in its current context. That context is larger than the visible conversation. It may contain:
- The platform's system prompt.
- Global instruction files.
- Local project instruction files.
- Memory files.
- Skill names and descriptions.
- Detailed skill instructions that have been invoked.
- Tool definitions.
- The active user request.
- Conversation history.
- File content.
- Research results.
- Browser observations.
- Command-line output.
- Error messages.
- Outputs returned by subagents.
Every component consumes tokens. The agent is not given an unlimited working space, so context must be managed as a finite resource.
This creates two connected optimization problems.
The first is quality. As the context becomes longer, the model may have more difficulty maintaining attention on the most important information. Earlier requirements can become harder to preserve. Unnecessary material can compete with the current task.
The second is cost. More tokens require more model processing. A large context may be processed repeatedly as the conversation continues, so information that appears harmless can become expensive when it is included in many calls.
Context engineering is therefore the discipline of deciding what must remain immediately available, what can be stored elsewhere, what should be retrieved only when needed, and what should be summarized or removed.