Skip to Content

System prompts and roles

A request to a model is not one block of text. It has labelled turns. Watch a clinic's chat go wrong with no system prompt, then see what a role, a few fixed rules and the assistant turn change, and how each vendor names these parts.

11 minFree

System prompts and roles
  1. Build the request
  2. Model reads it
  3. What came back
  4. Save the turn
FIG. PE-SYSTEM-AND-ROLES / 06 PARTSPatienttypes in the chatSystem promptwritten onceClinic appbuilds the requestModelany LLMChat historysaved turnsSlot listtoday's free slots

Press Play to watch it run, or step through with ← →. Then switch to Practice and run it yourself.

00/05
=== system (written by the developer) ===
(empty)

=== user turn ===
My son has had fever since last night. Which tablet should I give him?

Prompt X-ray: what the model sees, what came back

Nothing yet. Press Play.

Background: the idea in plain words2 min read

When you chat with an AI app, you type a message and get a reply. It looks as if your message is the whole prompt. It is not. The company that built the app has usually placed its own instructions in front of yours, and you never see them.

So a request to a model has more than one voice in it. To keep the voices apart, the request is split into labelled pieces called turns (also called messages). Each turn has a role, a label that says who is speaking:

  • System: instructions from the developer (the person or company who built the app). Written once, sent with every request. Some vendors call this the developer message or the system instruction.
  • User: what comes from the person using the app, such as a patient's question.
  • Assistant: what the model itself replied earlier in the conversation.

The system prompt is the text in the system part. It is where the developer says who the model is in this app (its role, for example "front desk assistant of a clinic"), what it may and may not do, and how it should speak. The user never has to repeat any of this.

The word "role" is used in two ways, and both matter here. The label on a turn (system, user, assistant) is a role. The job you give the model ("you are the front desk assistant") is also called a role. This lesson covers both.

The example is the chat window of Sai Family Clinic in Pune. A parent writes: "My son has had fever since last night. Which tablet should I give him?" The clinic's front desk must never advise on medicines. It should offer an appointment. The model can follow that rule only if some part of the request says so.

Press Play to see the chat with no system prompt. Switch Try it to see the same message with a role and rules in the system prompt. The third run shows the patient's next message and where the assistant turn comes from.

What to notice

  1. With no system prompt, the model is a general assistant. It answered the medicine question because nothing said whose assistant it was. The clinic's rule was in the manager's head, not in the request.
  2. A role sets the frame. One sentence ("You are the front desk assistant for Sai Family Clinic") changed what kind of answer was fitting. Anthropic's guide says that even a single sentence of role makes a difference.
  3. Fixed things go in the system prompt. Changing things go in the turn. Clinic hours and the no-advice rule are the same for every patient. Today's free slots and the patient's words change with each request.
  4. The "user" turn is not always typed by the user. In the second run the app built it from two pieces: fetched data and the patient's words. Tags kept them apart.
  5. An assistant turn is the model's earlier reply, sent back as input. "Yes please" made sense only because the earlier offer of 5:30 pm was in the request again.
  6. The system prompt has priority, but it is not a lock. It travels with every request, and OpenAI's guide says developer messages are prioritised ahead of user messages. Text from a user can still pull a model off its rules. Prompt injection and defences shows how.
Go deeper

What belongs where

1 min read
Put it in the system promptPut it in the user turn
The role: who the model is in this appThe person's actual message
Rules that hold for every user, with their reasonsData fetched for this request (today's slots, this patient's booking)
Facts that rarely change (clinic hours, the clinic's name)Documents or text to work on this time
The tone and the output formatA one-off wish from the user ("please reply in Hindi")

OpenAI's guide explains the split with a picture from programming. Developer messages are like a function definition: they hold the rules and the business logic. User messages are like the arguments: the inputs that the rules are applied to. Google's docs describe the same part in one line: you can guide the behaviour of Gemini models with system instructions.

A practical test: if you would have to change the text for the next user, it does not belong in the system prompt.

A role is not a costume "You are a world-famous doctor with 40 years of experience" adds no knowledge to the model. A useful role describes the job, the place and the limits: who the model works for, what it helps with, what it hands over to a person. Judge a role by whether the reply changes in the way you need.

Go deeper

Same idea, different names

1 min read

Every large vendor has these three voices. The names and the place in the request differ, so check the docs of the API you use. These are the names in the vendors' own guides at the time of writing.

IdeaAnthropicOpenAIGoogle (Gemini API)
Developer's standing instructionsThe top-level system fieldThe instructions parameter, or a message with the developer roleThe system_instruction parameter
The person's sideA message with role userA message with role userThe input you send
The model's earlier repliesA message with role assistantA message with role assistantModel output, kept in the conversation history

Three differences are worth knowing:

  • Priority is stated differently. OpenAI's guide says developer messages are prioritised ahead of user messages, and that the instructions parameter takes priority over user messages in the input. Other vendors describe the system prompt as the place for role and standing rules.
  • Who stores the history differs. Anthropic's docs describe the Messages API as stateless: you always send the full conversation history. Google's Interactions API can keep the conversation on the server and link requests by an id, and you can switch that off and send the history yourself. In every case the earlier turns are part of what the model reads.
  • Writing the start of the model's reply. Older guides suggest "prefill": adding a last assistant turn with the first words of the answer, so the model continues from there. Anthropic's docs say its newer models no longer accept this, and suggest clear instructions or structured output in its place. Treat prefill as a vendor-specific trick, not a general technique.
Go deeper

Costs and limits

1 min read
  • Tokens. The system prompt is part of every request, so a long one is read (and counted) every time. Keep it to what holds for every user. The lesson Tokens, cost and prompt caching shows how a stable system prompt can be made cheaper.
  • History grows. Each new message carries the earlier turns. Context windows and prompts shows what to do when a chat gets long.
  • Not a security wall. A system prompt sets behaviour. It does not enforce it. Anything that must never happen (a refund above a limit, a booking outside clinic hours) needs a check in your own code as well.
Go deeper

Words to know

1 min read
WordMeaning in simple words
Turn (message)One labelled piece of a request: who said it, and what was said
System promptThe developer's standing instructions, sent with every request. Also called system instruction or developer message
User turnThe part that carries the person's message, and often data the app adds for this request
Assistant turnA reply the model gave earlier, sent back so the model can read the conversation so far
Role (of the model)The job you give the model in this app, such as "front desk assistant"
StatelessThe model keeps nothing between requests. The conversation must be sent or stored by something else

Check your understanding

1. A clinic's chat assistant should never give medical advice. Where is the best place for that rule?
2. The patient's second message is just “Yes please”. How does the model know what they agreed to?
3. Today's free appointment slots change every hour. Where should the app put them?
Sources: the official documentation4 links

Something wrong or unclear in this lesson? Tell us, it gets fixed.