How to Write a System Prompt for an AI Agent (2026 Templates)

If your AI agent ignores instructions, calls the wrong tools, or goes off on tangents, the problem usually isn’t the model — it’s the system prompt. The system prompt is the agent’s job description: it sets the role, rules, and behavior for the entire session. Get it right and the agent becomes dramatically more reliable. Here’s the exact 6-part structure we use, plus a template you can copy.

Why the system prompt matters more than you think

A user prompt is a single task. The system prompt is persistent — it governs how the agent behaves on every turn, which tools it reaches for, and when it stops. A vague system prompt produces a vague, unpredictable agent no matter how good the underlying model is.

The 6 parts of a great agent prompt

Give it a clear role

Start by telling the agent who it is and its scope: “You are a support triage agent for an e-commerce store. You only handle order and refund questions.” A defined role prevents the agent from wandering into tasks it shouldn’t touch.

State the goal and ‘done’

Spell out the objective and the exact condition that means it’s finished. “Your goal is to categorize each ticket and draft a first reply. You are done when a draft and category are produced.” This is what stops loops and over-working.

List the tools and when to use them

Name each tool and its trigger: “Use search_orders when the customer references an order number. Use escalate when the request involves a chargeback.” Ambiguity here is a top cause of wrong tool calls.

Set the rules and guardrails

Put hard limits in their own section so they don’t get lost: what the agent must never do, when it must ask for human approval, and how to handle uncertainty (“If you’re unsure, ask rather than guess”).

Define the output format

Tell it exactly how to respond — plain text, JSON, a specific structure. Agents that feed other systems need strict formats: “Respond only with valid JSON matching this shape…” This prevents the malformed-output failures that crash pipelines.

Add one or two examples

Show, don’t just tell. A single example of an ideal input→output pair teaches the behavior faster than paragraphs of description.

The structure at a glance

The 6-part system prompt structureThe 6-part system prompt structureRolewho it isGoal + donewhat success isTools + ruleshow it actsFormat + exampleshow it replies
Figure 1: a reliable agent prompt moves from identity → goal → how it acts → how it responds.

Copy-paste template

Adapt this skeleton to your agent — fill in the brackets and delete what you don’t need:

# ROLE
You are a [role] for [context]. You handle only [scope].

# GOAL
Your goal is to [objective].
You are DONE when [explicit definition of done].

# TOOLS
- [tool_1]: use when [condition].
- [tool_2]: use when [condition].
Never call more than [N] tools per task.

# RULES
- Never [forbidden action].
- For [risky action], STOP and ask for human approval.
- If you are unsure or missing information, ask instead of guessing.
- Stop after [N] steps even if the task is incomplete.

# OUTPUT FORMAT
Respond using exactly this format:
[describe format / JSON shape]

# EXAMPLE
Input: [sample input]
Output: [ideal output]
Want to see these principles in real products?Our reviews show how the best agents handle prompting and control.

Learn more →

Common mistakes that break prompts

  • Burying the key rule in a wall of text — give hard rules their own section.
  • No stopping condition — always define “done” and a step cap.
  • Contradictory instructions — the agent can’t follow rules that conflict.
  • No output format — vague formatting breaks anything downstream.
  • Telling without showing — one concrete example beats three paragraphs.

Frequently asked questions

What should an agent system prompt include?
Six parts: a clear role, the goal and definition of done, the tools and when to use each, the rules/guardrails, the required output format, and one or two examples.
How is a system prompt different from a user prompt?
The system prompt sets the agent’s persistent role, rules, and behavior for the whole session. The user prompt is the specific task for a single turn.
Why does my agent ignore my instructions?
Usually the prompt is vague, contradictory, or buries the key rule. Be specific, separate hard rules, and show an example of the behavior you want.
Should I tell the agent when to stop?
Yes. A clear definition of done and explicit stopping conditions are among the most important lines in an agent prompt — they prevent loops and scope creep.
The OneAppleFall Team

We independently test every AI agent and tool we review — on our own dime, on real work. We never accept payment for a score, and we disclose affiliate links clearly. Read our review methodology →

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top