Agents
An agent is like a worker who can read the situation, decide what to do, and then do it — repeatedly. Unlike a single LLM call that returns one response, an agent operates in a loop: it observes the current state, thinks about the best action, acts, and then observes the result. This cycle continues until the goal is achieved or a limit is reached.
Prerequisites
Before reading this page, make sure you understand:
- Large Language Model (LLM) — how models generate text
- Tool Use — how models call external functions
How It Works
The diagram shows the observe-think-act cycle — the fundamental pattern behind every AI agent.
In the observe phase, the agent gathers context from its environment. This might mean reading a file, checking a test result, reviewing an error message, or examining what happened in the previous step. The agent builds a picture of the current state.
In the think phase, the LLM reasons about what to do next. Given the current context and the overall goal, it decides the best action. This is where the model's intelligence comes in — it's not following a fixed script, it's making a judgment call each time.
In the act phase, the agent executes its decision. It might call a tool (write a file, run a command, query an API), send a message, or produce output. This action changes the environment — a file gets created, a test passes or fails, data gets updated.
Then the cycle repeats. The agent observes the new state (did the test pass?), thinks about what to do next (fix the error or move on?), and acts again. This continues until the goal is met or the maximum number of steps is reached.
The key difference between an agent and a simple chatbot is persistence. A chatbot gives you an answer. An agent works through a problem iteratively, adapting its approach based on intermediate results — much like a human developer who runs code, reads the error, fixes it, and tries again.
Why It Matters
Agents can handle complex multi-step tasks that would be tedious to request individually. Instead of asking "write this function," then "now write the test," then "fix the failing test," you can say "build this feature with tests" and the agent will plan the approach, write code, run tests, fix errors, and iterate until it's done.
This is the pattern behind AI-powered code assistants like Claude Code, GitHub Copilot agents, and similar tools. Each one runs an observe-think-act loop internally, using tool calls to interact with your codebase.