Course contents
Prompting AI Agents
Write system prompts and tool descriptions for agents that loop: a mission, tools with clear triggers, a checkable definition of done, pause rules and grounded reports.
A chat prompt shapes one reply. An agent's system prompt governs a loop: the model plans, calls a tool, reads the result and decides what to do next, many times, with nobody checking in between. Vagueness that costs nothing in chat becomes a wrong tool call, a run that stops halfway, or an action you can't undo. Start with why small errors matter so much in a loop.
Move the controls and watch what changes.
Keep the defaults (95% per step, 20 steps), then switch on “Check each step and retry failures”. Roughly what happens to whole-run success?
What an agent prompt must say
- Mission and context. What the agent is for, who it serves and why the task matters. Anthropic's guidance for its Fable models says they do better when the prompt gives the reason behind a request, not only the request.
- Tools, and when to use each. Most of this lives in the tool descriptions themselves (next section).
- What done looks like. A completion condition the agent can check, and what to report when it gets there.
- Boundaries. Which actions need a person, what data it must never expose, and when to stop and say it's blocked.
Tool descriptions are prompts
The model picks tools by their names and descriptions, so most wrong-tool bugs are description bugs. Say when to use the tool, not only what it does: “Look up an order's current status. Use it whenever the customer gives an order id like ORD-12345” beats “Gets order data.” Show the argument format with an example, state side effects (“sends the email immediately; can't be undone”), and say how overlapping tools differ.
Tone matters too. Lines written to push older models into using a tool, such as “CRITICAL: You MUST use this tool when…”, can make current models over-trigger, and Anthropic's guidance is to soften them to “Use this tool when…”. Be explicit about action instead: current Claude models follow instructions precisely, so “Can you suggest some changes?” gets suggestions while “Change this function” gets edits.
A support agent keeps calling the wrong tools. Find the four lines in its tool set that cause trouble.
Define done, and what to do when stuck
Agents fail at both ends: they stop early, or they never stop. Write the completion condition into the prompt (“You're done when the refund is issued and the customer has a confirmation number; then summarize what you did”), and give the agent an exit: “If you're blocked, say what is blocking you instead of retrying the same call.” OpenAI's guide for its GPT-6 models tells agents to “persist until the user's intended goal is complete”. Anthropic's Claude Opus 5.5 guide warns harness builders to treat a text-only end of turn as a report, not as proof the task is done.
Back the prompt with code. Keep the task list in a file or a to-do tool the agent updates. If a turn ends with items still open and no blocker stated, send a short message naming them, and cap automatic continuations at two or three so a stuck run ends and gets reviewed. Hard limits on iterations and time belong in your loop, not in your wording.
The agent that stopped halfway
Your unattended agent is migrating five API endpoints to a new auth library. Nobody is watching the run.
After three endpoints, the turn ends with text and no tool call: “Migrated three endpoints and their tests. Next I'll migrate the remaining two.” Your harness has to decide what happens next.
Pause rules and grounded reports
Tell the agent exactly when to stop for a person; a list of every case isn't needed. Anthropic's sample for its Fable models is two sentences long. For long unattended runs, also make the agent audit its own claims: Anthropic reports that an instruction to check each progress claim against a tool result from the session nearly eliminated fabricated status reports in its testing.
Pause for the user only when the work genuinely requires them: a destructive or irreversible action, a real scope change, or input that only they can provide. If you hit one of these, ask and end the turn, rather than ending on a promise.
Before reporting progress, audit each claim against a tool result from this session. Only report work you can point to evidence for; if something is not yet verified, say so explicitly.Where should each rule live?
Sends immediately and can't be recalled.
search_docs when it should call lookup_order. What do you fix first?Plain-English definitions from the AI Coding Dictionary.