Topic 2 of 5 · 4 min read
Defining an agent's task and done state
Goal: Write a task definition for an agent feature with allowed actions, a budget, stop conditions and a checkable done state.
An agent task is a contract with six parts: the input, the allowed tools and actions, a budget, stop conditions, a done state you can check, and a rule for handing back to a person.
Check yourself · 1 of 3
Which of these is a checkable done state for an agent that drafts replies?
Why it matters
An agent loops: it picks a step, uses a tool, reads the result and picks again. Without boundaries the loop has no natural end. It may keep trying, spend money, wander into tools it should not touch or declare success when nothing worked. Anthropic's "Building effective agents" notes that agents should stop at set points, such as a maximum number of iterations, and pause for human feedback at checkpoints or blockers. The boundaries are product decisions, and the PM writes them down before engineering builds.
The six parts
- Input. What the agent receives: a ticket, a form, a file. Say what it must not assume.
- Allowed tools and actions. A short list. "Read the order database, draft a reply" is a boundary. "Use any tool you need" is not.
- Budget. A cap on steps, time and cost per run, for example 15 tool calls or 2 minutes or 40 cents.
- Stop conditions. What ends a run early: the budget is hit, two tool calls fail in a row, the request is outside scope, the agent is unsure.
- Done state. A result you can check without trusting the agent's word. "The reply is saved as a draft and cites an order number that exists" can be checked. "The customer is helped" cannot.
- Hand back. When and how a person takes over, with what the agent already did written down so they do not start from zero.
Before and after
Before: "The agent handles shipping questions."
After: "Input: one customer message and the order id. Tools: read order status, read carrier tracking, save a draft reply. No refunds, no edits to orders. Budget: 8 tool calls, 60 seconds. Stop and hand back if tracking is missing, the customer asks for money, or two calls fail. Done: a saved draft that quotes the current carrier status and the order id."
A tester can write a pass or fail check for every line.
What goes wrong
- A done state based on the agent's own claim. Agents sometimes report success after a failed step, so verify against the system of record.
- No budget. One bad loop can cost more than a hundred good runs.
- Stop conditions that only say "if unsure". The model is rarely the best judge of its own doubt, so add rules that do not depend on its confidence.
Examples
A shipping-question agent
Input: one customer message plus the order id.
Allowed: read order status, read carrier tracking, save a draft reply.
Not allowed: refunds, changing an order, sending the reply.
Budget: 8 tool calls, 60 seconds.
Stop and hand back: tracking is missing, the customer asks for money, or two tool calls fail in a row.
Done: a saved draft that quotes the current carrier status and an order id that exists.
Weak done state, fixed
Before: Done means the agent says it fixed the problem.
After: Done means the ticket status is Resolved in the helpdesk, a reply is saved, and a rerun of the original search returns no open duplicates. The check reads the helpdesk, not the agent's summary.
Key points
- A task definition has six parts: input, allowed actions, budget, stop conditions, done state and hand back.
- The allowed actions are a short named list, not 'whatever tools it needs'.
- Budgets cap steps, time and cost for each run.
- A done state must be checkable against a real system, not the agent's claim.
- Stop conditions should include rules that do not rely on the agent judging its own confidence.
Common mistakes
- Writing the done state as the agent's own statement of success.
- Leaving the allowed tools open-ended.
- Setting no step, time or cost budget per run.
- Handing back to a person with no record of what the agent already tried.
Check yourself · 2 of 3
Why does an agent task need a budget of steps, time and cost?
Check yourself · 3 of 3
A stop condition for an agent says only: 'stop if you are not confident'. What is the main weakness?
Practice items, not counted towards your mastery.
Start here
- Building effective agents (Anthropic) (opens in a new tab)ArticleFree
Separates fixed workflows from agents and says where to add human checkpoints and stop conditions.
- A practical guide to building agents (OpenAI) (opens in a new tab)ArticleFree
Covers guardrails, tool risk ratings and when to hand control back to a person.
- Levels of autonomy for AI agents (Knight First Amendment Institute) (opens in a new tab)PaperFree
Defines autonomy as a design choice with named levels, separate from how capable the model is.
More for this topic
- Writing effective tools for AI agents (Anthropic) (opens in a new tab)ArticleFree
How the tools you give an agent shape what it can do and how it fails.