An AI agent is an application that uses a model to decide what to do next. It can use the result of one action to choose the next. For example, an agent investigating a failed deployment might read the build log, see that a test failed, and open the test file to find out why. If the log shows an expired credential instead, it investigates the credential.
For any proposed agent, trace one run and identify three things: when it starts, which decisions the model makes, and which checks the application enforces.
Distinguish a model, a workflow and an agent
| Term | What it means | Deployment example |
|---|---|---|
| Model | The component that interprets input and produces an answer or proposes an action | Read the error and suggest opening a test file |
| Tool | A function the application makes available, with known inputs and results | read_file(path) returns the contents of a repository file |
| Fixed workflow | Application code decides the steps and when to take each branch | Read the build log and send it to the on-call engineer whenever a build fails |
| Agent | A model chooses some of the steps based on the results it sees | Decide which files to inspect and which tests to run |
| Runtime | The application code that runs the task, checks permissions and limits, and records results | Allow tests in an isolated copy of the repository and require separate permission to deploy |
One application can use both approaches. A fixed workflow can start an investigation when a build fails, let an agent choose how to investigate, and then send its proposal to an engineer for review. Anthropic uses the same distinction between paths defined in code and paths chosen by the model. Building effective agents.
Ground the idea in one task
The request is to explain why the deployment failed and propose a tested repair. The application can read build logs and repository files. It can also edit and run tests in a separate copy of the repository.
- The build log says the application cannot start because it is missing the
PAYMENTS_URLsetting. - The model proposes opening the deployment configuration and the test that checks required settings. The application permits both reads.
- The configuration still uses
PAYMENT_URL, while the test checks forPAYMENTS_URL. The model proposes renaming the setting in the isolated workspace and running the configuration test. - The test passes. The agent reports the old and new setting names, the proposed change, and the test result. An engineer can review and approve a deployment separately.
If the log showed a network timeout, the investigation would take a different path. That is where the model's ability to choose a next step helps.
Define the control loop
The control loop is the part of the runtime that repeats a sequence: ask the model for the next step, check whether it is allowed, run it, and use the result to decide whether to continue. An observation is a result the runtime can pass back to the model, such as file contents, a failed test, or a tool error. This lesson uses those names to describe the design. Frameworks may use different names for the same responsibilities.
Read diagram source
flowchart TD
A["Start with the task and known results"] --> B["Model proposes a next step"]
B --> C{"Action allowed and within limits?"}
C -->|Yes| D["Run tool and record what happened"]
C -->|No| F["Request approval or report what blocked progress"]
D --> E{"Do the results meet the goal?"}
E -->|Yes| G["Report the result and the checks that passed"]
E -->|No, more work is possible| A
E -->|No, work cannot continue| F
For the example above, the model sees the missing setting and proposes read_file. The runtime checks that the path is inside the allowed repository. The file contents become the next observation. That read helps explain the failure, but the requested repair still needs a test. The loop continues until the evidence supports the result or the application reaches a stopping rule.
Name the components precisely
| Component | What to decide | Example |
|---|---|---|
| Goal and completion checks | What outcome did the user ask for, and how can you confirm it? | Name the cause, show the change, and run the relevant test |
| Tool inputs and permissions | Which arguments are valid, and who can use the tool? | Allow reads from the repository. Block access to unrelated files and secrets |
| Task state | What should survive if the process restarts? | Keep the build ID, completed checks, tool results, and remaining work |
| Limits and stopping rules | When should the application stop or ask for help? | Stop after a time or spending limit, or when further attempts repeat the same error |
A log file can contain text supplied by a user or an external system. If it tells the model to upload the repository, the application checks that request against the original task and permissions. The log supplies evidence about the build. It cannot give the agent permission to send files. Tool use and MCP.
Separate context, memory and compute caches
| Term | What it holds | Example |
|---|---|---|
| Context | Information sent to the model for this call | The request, the relevant lines from the build log, and the last test result |
| Task state | The application's record of what has happened in this run | Test config_required_settings passed. No deployment has been requested |
| Persistent memory | Selected information kept for future runs | This team uses a particular configuration check before proposing changes |
| KV cache | Computation the model can reuse for an unchanged beginning of its input | Reuse work for the same instructions at the start of successive calls |
A brief investigation can fit in one process. If the work must resume after a restart, save the task state in durable storage. Keep information across separate tasks only when there is a clear reason to reuse it. Agent memory and state.
What L0–L4 mean in the original guide
The original guide grouped designs under L0 through L4. These labels describe that author's classification. Here is what each label means in the guide. Original guide's agency levels.
| Label in the original guide | What it means | Deployment example |
|---|---|---|
| L0 — Scripted chain | Code fixes the sequence of steps. | Every failed build triggers the same log collection and alert. |
| L1 — Tool-enabled | The model picks a tool for the current request without making a plan. | Choose whether to fetch the build log or read a configuration file. |
| L2 — ReAct agent | The model repeatedly uses an action's result to choose another action. ReAct is short for reasoning and acting. | Read the log, open a file based on the error, and choose a test based on the file. |
| L3 — Autonomous planner | The model breaks the goal into smaller tasks and decides which steps depend on others. | The model plans to inspect the configuration and startup checks in parallel. It schedules the verification test after the proposed repair. |
| L4 — Ambient agent | The system can run in the background and act or notify someone when needed. | Watch failed deployments and prepare a report before anyone asks. |
Other authors use level numbers for different properties. Feng and colleagues define five levels, L1–L5, by the role the user plays, from directing the work to observing it. In the original guide's classification, an L4 agent can start work in the background and still need approval for every write. A timer tells you when the work starts. Look at what the system is allowed to do to understand who can change production. Levels of Autonomy for AI Agents.
A build-failure agent can start when CI reports an error. The model chooses which logs and tests to inspect. The deployment service waits for an engineer’s approval before deploying.
Choose model effort using evidence
Some model APIs let you request more computation for a difficult decision. Try it when the cheaper setting has trouble with a real task, such as distinguishing a bad migration from a network failure. Compare how often each setting identifies the right cause, chooses valid tools, and produces a tested repair. Measure time and cost for the whole run. Names such as “System 1” and “System 2” come from a human thinking analogy. Check each API for the model and settings it actually offers. Reasoning training.
For a small decision, you may only need a value such as CONFIG, NETWORK, or UNKNOWN. OpenAI made its Decisions API generally available on October 22, 2026. It can return answers in a predefined format, such as a choice from a list. The runtime can use that choice to route the investigation. It still checks permissions before running any tool. OpenAI API changelog · Decisions API.
Prevent drift and recognize completion
- Keep the request in view. If the user asked for a repair proposal, stop before deployment.
- Record what has been checked. Keep the build ID, test results, and open questions so a later step can pick up the work.
- Stop repeated failures. If the same file read keeps returning “permission denied,” ask for access or report the blocker.
- Check the requested outcome. If the proposed configuration passes its test but no deployment was attempted, report exactly that.
- Check uncertain results before retrying writes. If a ticket creation call times out, look up its operation ID first. The ticket may already exist even if the application never received the response.
If five required steps each succeed 95% of the time and their failures are independent, all five succeed about 77% of the time (0.95^5). The assumptions make this an illustration. Measure complete runs on your actual tasks, including how often the system recovers and how often it stops without finishing.
Interview practice
Q1: What makes this application agentic?
The model uses the results it sees to pick some of the next steps. In the deployment example, the failure message determines which files the model asks to inspect. The application still sets the permissions and stopping rules.
Q2: Does an agent require persistent memory?
A short task can use the current request and the results collected during that run. Save task state if it must resume later. Keep information across separate tasks only if future runs need it and users can control what is retained.
Q3: Is a reasoning model automatically safer for tool use?
Check whether it chooses better actions on representative tasks. Either way, the runtime checks that the arguments are valid, the caller has permission, and the action stays within the allowed budget.
Q4: How do you prevent an agent from wandering away from its task?
Keep the original request and track the work that remains. If a step is outside the request, block it. If attempts keep failing in the same way, stop or ask for help. Run the agreed checks before reporting success.
Q5: What is the difference between a failed action and an unknown outcome?
If the ticket service rejects a request before writing, it confirms that no ticket was created. If the call times out, the service might have saved the ticket before the connection dropped. Look up the operation before trying again.
Q6: How do you know the agent is done?
Compare the results with the request. For the deployment example, report the identified cause, the proposed change, and which test passed. State any part you could not verify.
Final notes
Recall card: The model proposes a step. The runtime checks it and runs the tool. The result helps choose the next step or verify that the task is complete.