A8gent
GlossaryAgent concepts

What is system prompt?

Also called: system message, agent instructions

A system prompt is the standing instruction block sent at the top of every request, defining an AI system's role, rules, tone and output format before the user's input is read.

Written by A8gent
Contents
  1. At a glance
  2. What a system prompt is
  3. How to write one that works
  4. Cost, caching and length
  5. What you should know
  6. FAQ
  7. Related terms

At a glance

Category
Core agent concept
Position
First message in every request, ahead of the conversation
Five useful sections
Role and context, task and rules, hard constraints, output schema, worked examples
Cost
Re-sent on every model call, including every step of an agent loop
Caching
Keep stable content at the top so provider prompt caching can reuse the prefix
Not
A security boundary - anything that must hold under attack belongs in code

What a system prompt is

A system prompt is the block of instructions that sits at the top of every request to a model, ahead of the conversation. It defines who the assistant is, what it may and may not do, what format the output must take, and what to do when it does not know. Providers give it a privileged position in the message list, and models are trained to weight it more heavily than user text - but it is still text, which is the whole story of prompt injection.

In a business automation the system prompt is where most of your product actually lives. The model is a commodity; the difference between an automation that books jobs correctly and one that annoys customers is usually two hundred well-chosen words about your business, your policies and your edge cases.

How to write one that works

Structure beats prose. A system prompt that works in production usually has five parts: role and context ("you triage inbound enquiries for a plumbing company in Leeds"), the task with its decision rules, hard constraints stated as absolutes, the output format with an explicit schema, and worked examples covering the edge cases. Examples do more work than adjectives - one example of a two-questions-in-one-message enquiry handled correctly beats a paragraph asking the model to be careful.

Be specific about failure. State exactly what to output when the answer is not available, when the input is spam, when a field is missing. Models invent when the prompt leaves them no legal way to say they do not know, which is a major driver of hallucination. And state the negative constraints concretely: "never quote a price" is followed far more reliably than "be careful about pricing".

Cost, caching and length

The system prompt is re-sent on every request, and in an agent loop that means every step. A thousand-token system prompt on a ten-step run is ten thousand input tokens before anything useful happens. That is affordable on cheap models and worth watching on expensive ones - see token.

Prompt caching changes the arithmetic. The major providers let you mark a stable prefix so that repeated requests reuse it at a heavily discounted input rate, which suits a fixed system prompt perfectly. To benefit, keep the stable content at the top and anything variable at the bottom - a timestamp near the start of the prompt invalidates the cache for everything after it. Check your provider's current cache pricing and minimum-length rules, as both change.

What you should know

A system prompt is not a security boundary. It sets defaults and it is doing most of the work in normal operation, but anything that must hold under attack belongs in code as a guardrail. The test: if a jailbroken model could ignore it, it was a preference.

Version your prompts like code. Keep them in the repository rather than pasted into a platform's UI, note what changed and why, and re-run your eval set on every edit. Prompts are the component most likely to be changed casually by whoever is nearest, and the component whose regressions are hardest to spot.

System prompt FAQ

What is a system prompt?

The standing instruction block sent at the top of every request, defining the assistant's role, rules, output format and fallback behaviour before any user input is read. Models are trained to weight it above user text, but it remains text rather than an enforced constraint.

How long should a system prompt be?

As long as the edge cases require and no longer, because it is re-sent on every call including every agent step. Most production prompts land between 200 and 800 words. If yours is much longer, it usually means rules that belong in code have been written as prose.

Should I put examples in the system prompt?

Yes - they are the highest-value content in it. One worked example of an awkward case does more than several paragraphs of instruction. Pick examples from real production failures rather than inventing tidy ones, and update them as new failure shapes appear.

Does the system prompt stop the model doing forbidden things?

Not reliably. It shapes normal behaviour well, but injected content can outweigh it and users can talk around it. Spend limits, tool permissions and forbidden actions have to be enforced outside the model, in the code that executes tool calls.

How does prompt caching affect my system prompt?

Providers offer a discounted rate for reusing a stable prefix across requests, which fits a fixed system prompt exactly. To benefit, keep everything stable at the top and anything variable - dates, customer details, retrieved context - at the bottom, since a change invalidates the cache from that point onward.

Where should I store my prompts?

In version control alongside your code, not pasted into a platform UI. You want the history, the review, and the ability to roll back. Re-run your eval set on every change, because prompt regressions are silent - nothing errors, the output is simply slightly worse.

Primary source

OpenAI - Prompt engineering guide

Checked August 2026. Anything priced or rate-limited moves, so verify against the source before you budget.

Want this built rather than explained?

Knowing what system prompt means is one thing; having it running in your business is another. We scope one workflow at a time, quote a fixed price in writing after a free consult, build it, and hand it over with documentation you own.