Chat-style models separate durable policy from the live request. The system prompt (system message) holds identity, safety, format contracts, and tool rules that should not change every turn. The next lecture covers the complementary user prompt.
System prompts often encode earlier techniques—roles, JSON schemas, and Markdown skeletons—so products stay consistent across sessions.
Learning Objectives
By the end of this lesson, students should be able to:
- Define the system prompt and distinguish it from user/assistant turns.
- Place policy, persona, and output contracts in the system message.
- Keep system prompts stable, versioned, and testable.
- Avoid stuffing volatile task data into the system role.
- Coordinate system rules with guardrails outside the model.
- Debug conflicts between system and user instructions.
A system prompt is the high-priority instruction message (role system in chat APIs) that sets the assistant’s standing behavior—persona, policies, tools, and output format—across a conversation, independent of any single user query.
What Belongs in System vs. User
| Layer | Put here | Avoid here |
|---|---|---|
| System | Persona, safety, format, tool policy | Huge one-off documents |
| User | Question, task inputs, per-request context | Contradicting core safety |
| Assistant | Prior model replies (history) | Secret credentials |
Who the assistant is.
Do / don’t policies.
JSON / MD / tools.
When to refuse / hand off.
Good system content
- Brand voice
- Refusal categories
- Schema reminder
Move to user
- Today’s ticket text
- Retrieved chunks
- One-shot examples per task
Outside the model
- Auth & quotas
- PII filters
- Hard blocklists
Practical API Example
Strengths
- Consistent behavior across turns
- Central place for policy & format
- Easier product-wide updates
Tradeoffs
- Overlong systems waste tokens
- Conflicts with clever user overrides
- Not a substitute for external guardrails
“The system prompt is an unbreakable security boundary.” Models can still be steered by adversarial user content. Treat system text as soft policy; enforce hard safety with guardrails, filters, and privilege separation.
Knowledge Check
- Short Answer: What is a system prompt? Answer: The standing chat message that sets durable assistant behavior/policy.
- True/False: One-off ticket text usually belongs in the system role. Answer: False—put it in the user message.
- Multiple Choice: System prompts commonly hold: (a) persona and format rules, (b) GPU firmware, (c) raw weight tensors. Answer: (a).
- Short Answer: Why version system prompts? Answer: To reproduce behavior and attribute eval/regression changes.
- True/False: System prompts alone guarantee safety against injection. Answer: False.
- Multiple Choice: Auth and quotas should live: (a) outside the model, (b) only in witty system jokes, (c) in temperature. Answer: (a).
- Short Answer: Name a conflict to watch for. Answer: User instructions that contradict system safety/format rules.
- Short Answer: What should you log with each call? Answer: prompt_version (and related config IDs).
- Multiple Choice: Overlong system prompts mainly risk: (a) token cost and dilution, (b) faster GPUs, (c) free context. Answer: (a).
- True/False: The next lecture covers the per-request user prompt. Answer: True.
Key Takeaways
- System prompts hold durable identity, policy, and format.
- Keep volatile task data in the user turn.
- Version and evaluate; back with external guardrails.
- Next: User Prompt.
Hands-on: Split a messy all-in-one prompt into system vs. user; compare consistency over 10 queries.
Discussion: How short can a production system prompt be while still encoding brand + safety?
Recap: The system prompt is your product’s standing contract with the model. Continue with User Prompt.