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

  1. 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.
  2. The model uses it together with behaviour learned in training; models trained with an instruction hierarchy rank system instructions above user instructions.
  3. It takes up context window space on every request, so a long system prompt raises the cost of each answer.
  4. 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

TermHow it differs
Chat templateA 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.

ON-PREMISES EXAMPLE

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.

Sources

Related page on this site: Guide: On-premise enterprise AI · In the glossary: Glossary, R to Z

What does this term mean for your infrastructure?

We can work out together in a technical assessment how it maps onto your data, hardware and security requirements.

Request a technical assessment →

This site sets no cookies. Visitor numbers are counted in aggregate using a cookieless method that does not identify anyone. See the Privacy Policy for details.