Agent Loops
An agent is a system that perceives its environment and takes actions to achieve a goal.
The Loop
An agent runs in a loop:
- Receive input
- Predict the next tokens—which may specify a tool call
- The system executes any tool calls
- Tool output becomes part of the context
- Repeat until complete
Each iteration extends the context. The context accumulates information about your codebase, file states, and previous attempts.
Why Tools Matter
Without tools, an LLM can only generate text. With tools, it can:
- Read and write files
- Run terminal commands
- Search codebases
- Make API calls
The tools define what the agent can actually do in your environment.