What is a system prompt?
A system prompt is the instruction given to a model before the user's input that sets the model's role, tone and the rules it must follow.
It differs from a prompt in scope: the prompt is all input sent to the model, while the system prompt is its privileged part that sets role and rules. On its own it is not a security control; prompt injection can override it and it can leak.
- Topic
- Prompts, context, reasoning and generation
- Also known as
- System message, system instruction
How a system prompt works
- The application sends the system prompt as a role separate from the user message; the chat template places it at the start of the context with special role markers.
- The model uses it together with behaviour learned in training; models trained with an instruction hierarchy rank system instructions above user instructions.
- It takes up context window space on every request, so a long system prompt raises the cost of each answer.
- In enterprise setups system prompts are versioned and changes are reviewed.
In more detail
Prefix caching and where to place dynamic fields
Because the system prompt sits at the exact start of the context, keeping it static enables KV or prefix caching in modern inference engines (such as vLLM or SGLang). Placing dynamic fields such as timestamps, session IDs or per-user memory after the static prefix avoids invalidating the cache and sharply cuts latency and compute cost.
Developer messages and the multi-tier instruction hierarchy
Modern model ecosystems distinguish the model provider's root system rules from the application builder's developer prompt, user messages and untrusted tool outputs. This multi-tier instruction hierarchy makes it harder, though still not impossible, for untrusted text inside retrieved documents or web pages to override application policy.
Instruction drift in long contexts and indirect injection
Even well-crafted system prompts lose influence in very long conversations or multi-document RAG contexts ("lost in the middle" and instruction drift) and can be bypassed via indirect prompt injection inside retrieved data. Critical constraints should be reinforced via structured output schemas, deterministic post-checks or periodic rule reminders.
Commonly confused terms
| Term | How it differs |
|---|---|
| Chat template | A chat template is the model-specific token formatting syntax (such as special role markers) used to serialise system, developer, user and tool messages; the system prompt is the policy text placed inside the system slot of that template. |
Why a system prompt matters for on-premises AI
It is the first way to pass organisational policy, answer style and off-limits topics to the model. Secrets, passwords or permission rules are never written into it, because the model can leak its content (system prompt leakage). Access control, input validation and tool permissions are built separately in the application layer. Versioned prompts and change logs help track and audit assistant behaviour.
An insurer's system prompt tells its support assistant never to invent policy terms and to answer only from the approved knowledge base; access rules are enforced in the application layer.
Common questions
Is a system prompt enough as a security control?
No. Controls such as access management, input validation and tool permissions must be designed separately in the application layer.
Can a system prompt be hidden from users?
The application may not display it, but it cannot be hidden from the model and can be leaked, so no secrets go into it.
Related terms
- Prompt
- Instruction hierarchy
- System prompt leakage
- Role prompting
- Prompt injection
- Chat template
- Prompt engineering
- Prompt template
- Prompt management
Sources
- Wallace et al., The Instruction Hierarchy: Training LLMs to Prioritize Privileged Instructions, 2024
- OWASP Top 10 for LLM Applications 2025, LLM07: System Prompt Leakage
Related page on this site: Guide: On-premise enterprise AI · In the glossary: Glossary, R to Z