Topic 3 of 4 · 3 min read
System prompts and instruction priority
Goal: Predict how a model resolves a conflict between a system prompt and a user message and why the same model acts differently in two apps.
A system prompt is hidden text, written by the app's maker, that comes before your message and shapes everything the model says. Models are trained to rank system instructions above user ones, but the ranking is a habit, not a lock.
Check yourself · 1 of 3
Why can the same model act very differently in two apps?
Why it matters
The same underlying model can feel very different in a coding tool, a customer-support bot and a general chat app. Most of that difference is the system prompt: tone, rules, topics to avoid, tools it may use, even its name. Knowing this stops you blaming "the AI" for what is really an app setting. Some providers publish the prompts used in their own apps, so you can read examples.
How priority works
Models are trained to follow an instruction hierarchy, roughly:
- System instructions from the developer or app.
- User instructions.
- Everything else: tool results, web pages, files.
When a system prompt says "answer only in French" and the user writes "reply in English", a well-trained model usually follows the system prompt, or follows the user if the system prompt allows it. Training makes this likely, not certain. Long chats, clever wording and conflicting rules can tip it the other way.
Before and after
Weak: A support bot's system prompt says "Be helpful." A user asks for a refund beyond policy. The bot has no rule, so it improvises a yes.
Better: "You answer questions about Acme orders. Refunds are only possible within 30 days. If a request falls outside policy, say so and offer a human agent. Never promise a refund yourself."
The second prompt gives a clear rule and a clear fallback. It is much harder to talk around.
What goes wrong
- People assume rules in the system prompt are guaranteed. A model can break them, so rules that must hold (payments, permissions, private data) belong in code, not only in a prompt.
- People assume what they cannot see does not exist. If a tool behaves oddly, ask what instructions it carries. You often cannot read them, and the model may not reveal them.
- Conflicting rules lead to unpredictable results. "Always be brief" plus "explain every step" leaves the model to guess.
Optional code branch
Developers set the system prompt separately from the messages:
response = client.messages.create(
model=MODEL,
system="You answer only about Acme orders. Offer a human for refunds past 30 days.",
messages=[{"role": "user", "content": "Refund my order from 90 days ago."}],
)
Examples
One model, two apps
A legal-research app tells the model to cite sources and refuse to guess. A creative-writing app tells it to be playful and inventive. Same model, opposite behaviour on "Tell me about this case", because the first sentence of the hidden prompt differs.
A conflict
System: "Reply only in Spanish." User: "Answer in English from now on." Most models keep Spanish. If the system prompt had said "Reply in the user's language", English would win. Clear wording decides it.
Key points
- A system prompt is hidden text from the app maker that comes before the conversation.
- The same model behaves differently across apps mainly because of different system prompts, tools and settings.
- Models are trained to rank system instructions above user ones, and user ones above pasted data.
- The ranking is a learned tendency, so it can fail.
- Rules that must always hold should be enforced in code, not only in a prompt.
Common mistakes
- Blaming the model for behaviour that comes from the app's hidden prompt.
- Putting a safety or permission rule only in the system prompt.
- Writing system prompts with rules that contradict each other.
- Assuming the user can always override or always cannot override the system prompt.
Check yourself · 2 of 3
A system prompt says "Never discuss pricing." The user asks for prices. What does a well-trained model usually do?
Check yourself · 3 of 3
Your app must never reveal a customer's account number. Where should you enforce that?
Practice items, not counted towards your mastery.
Start here
- Chat templates (Hugging Face Transformers docs) (opens in a new tab)DocsFree
Shows how a list of role-tagged messages is rendered into the single text a model reads, with special tokens.
- Working with messages (Claude docs) (opens in a new tab)DocsFree
Shows that each API call carries the full conversation and that the API keeps no state for you.
- System prompts release notes (Claude docs) (opens in a new tab)DocsFree
Anthropic publishes the real system prompts used in its apps, so you can read what a hidden prompt looks like.
More for this topic
- The Instruction Hierarchy (Wallace et al., 2024) (opens in a new tab)PaperFree
The research behind ranking system, user and tool text, and why models need training to follow that order.