Module 4 · Structured outputs & tools
System prompts for agents
6 min read
An agent's system prompt is not a chatbot's. An agent chains dozens of tool calls, decides on its own when to search, when to act, when to stop — and each of these decisions is guided by a text written once and for all. An agent's system prompt is a behavior policy: it says who acts, for whom, with what means, within what limits, and how to report. This lesson gives its structure, illustrated by Quill's back-office assistant.
What an agent needs to know
| Section | Question | Example for the back-office assistant |
|---|---|---|
| Identity and mission | Who am I, for whom, to do what? | Assistant to the Nimbus store's support team |
| Context | What must I know about the environment? | Orders use the CMD-xxxxx format; supplier invoices the F-xxxxx format |
| Tools | When to use what? | See the tool descriptions (lesson 4.2); here, only cross-cutting rules |
| Action rules | What can I do alone, what must I confirm? | Refund: only on explicit request; above €100, ask for confirmation |
| Limits | What must I never do? | Never share another customer's data; never promise an unconfirmed delay |
| Handling uncertainty | What to do when I don't know? | Say so, and create a ticket rather than guess |
| Stopping | When am I done? | When the request is handled or handed over; summarize the actions taken |
| Report format | How to answer the user? | Two sentences at most, then the list of actions taken |
An agent system prompt
Quill's prompts/agent_back_office/v1.md file:
Tu es l'assistant de l'équipe support de la boutique Nimbus. Tu traites les demandes internes des conseillers :
suivi de commandes, remboursements, factures fournisseurs, contrats, stock.
<contexte>
Numéros de commande client : CMD-xxxxx. Factures fournisseurs : F-xxxxx. Les montants sont en euros TTC.
</contexte>
<regles>
- Agis avec les outils plutôt que de supposer : une information non vérifiée par un outil n'est pas une information.
- Un remboursement n'est déclenché que si le conseiller le demande explicitement. Au-delà de 100 €, résume
l'opération et demande confirmation avant d'appeler refund_order : un remboursement ne s'annule pas.
- Si aucun outil ne permet de répondre, ou si la demande sort de ton périmètre, crée un ticket et dis-le.
- Ne communique jamais d'informations sur un client autre que celui de la demande en cours.
</regles>
<compte_rendu>
Réponds en deux phrases au plus, puis liste les actions effectuées (outil, paramètres, résultat).
</compte_rendu>
(Mission: assistant to the Nimbus support team for orders, refunds, supplier invoices, contracts, stock. Rules: act with tools rather than assume; refund only on explicit request, and above €100 summarize and ask for confirmation because a refund cannot be undone; create a ticket when no tool can answer; never share information about another customer. Report: two sentences at most, then the list of actions.)
Notice what this prompt does not contain: no alarm capitals ("YOU MUST ABSOLUTELY"), no list of twenty prohibitions. Current models follow their system prompt closely; dramatic injunctions, useful with older distracted models, now lead to excessive behaviors — an agent that calls a tool at every sentence because it was shouted at to "ALWAYS use the tools". Each rule carries its reason ("a refund cannot be undone"): that is what lets the model generalize to cases the rule did not foresee.
Action rules: the heart of the matter
The most important question of an agent prompt is: what can it do alone? A simple grid:
| Type of action | Example | Rule |
|---|---|---|
| Read | View an order, a stock level, a contract | Free |
| Reversible write | Create a ticket, add a note | Free, reported in the summary |
| Irreversible or costly write | Refund, email the customer, delete | Explicit confirmation, or threshold |
This grid does not go only in the prompt: it is coded. The refund_order tool can itself refuse an amount above a threshold without a confirmation token. The prompt guides the model; the code guarantees the rule (the same principle as in lesson 4.4 against injections).
With the Claude API
def call_tools(request: str, tools: list[dict], system: str) -> list[tuple[str, dict]]:
"""Outils au format Claude : `input_schema`, et `strict` pour garantir des arguments conformes."""
response = client().messages.create(
model=config.CLAUDE_MODEL,
max_tokens=2000,
system=system,
tools=[{**t, "strict": True} for t in tools],
messages=[{"role": "user", "content": request}],
)
return [(b.name, b.input) for b in response.content if b.type == "tool_use"]
Three points specific to current Claude models:
- You do not force a tool: on Claude Opus 5.5 and Sonnet 5.5,
tool_choice"any" or "tool" returns a 400 error. You guide with the prompt ("use the get_order_status tool to…") and check that a call actually happened. strict: trueguarantees that arguments follow the tool's schema (this requiresadditionalProperties: false).- The system prompt must stay stable: it sits at the head of the prompt, with the tools, and forms the prefix cached at each turn of the loop (lesson 3.4). A date or session identifier inserted into the system prompt invalidates the cache at every request; inject such information later in the conversation.
Testing an agent prompt
An agent prompt is tested on scenarios, not isolated questions:
- a simple request (a single tool);
- a compound request (several tools, in the right order);
- an out-of-scope request (must end in a ticket, not an invention);
- an ambiguous request (must ask a question or state its assumption);
- an irreversible action (must ask for confirmation);
- a manipulation attempt (lesson 4.4).
For each, you check the trajectory (which tools, with which arguments) as much as the final answer. The evaluation tools of lesson 5.2 apply: a test case, assertions on the tool calls.
Key takeaways
- An agent's system prompt is a policy: mission, context, action rules, limits, uncertainty, stopping, report.
- Each rule carries its reason; avoid dramatic injunctions, which cause excesses on current models.
- Distinguish reads, reversible writes and irreversible writes; also code the safeguards into the tools.
- With Claude: no forced
tool_choiceon Opus 5.5 and Sonnet 5.5,strict: truefor arguments, a stable system prompt for caching.- Test on scenarios, checking the trajectory of tool calls.
Practice
- Write the system prompt of an agent in your company with the eight sections of the table.
- Classify its tools into reads, reversible writes and irreversible writes, and write the confirmation rule.
- Write six test scenarios (one per category above) with the expected trajectory.