Overview
Every loop adds information. The initial context may contain only the user's request and the system instructions. After the first tool call, the context also contains the tool result. After the next action, it contains another result. If the agent encounters an error, the error becomes part of the context. If it researches a topic, the research becomes part of the context. If it edits a file, the change and the surrounding discussion may also become part of the context.
This growth is useful because it allows the agent to learn from the task while it is performing the task. It can remember what failed, compare new evidence with the original goal, and revise its plan.
The same growth also creates a management problem. A larger context consumes more tokens, costs more, and can reduce output quality. Context management is therefore not separate from agent design. It is one of the core operating disciplines and is examined in detail in Lesson 5.