← Claude & OpenAI Made Easy
18 min

Messages and Roles: Who Says What to the Model

A chat is a list of messages with roles. Learn what goes in the rules and what goes in the request.

Lesson 1 of 11
0 done
In plain English

A chat with an AI is a list of messages, and each message has a role. The top role holds the rules. The user role holds the request. The model remembers nothing, so the app resends the history each time.

Role
Who is speaking: the rules, the user or the assistant.
System prompt
The top rules, also called the developer message.
History
The earlier messages that are sent again each turn.
Picture it
Who says what
Top rules
System prompt or developer message
Earlier messages
The history, sent again each turn
User message
The request and the material

When you chat with an AI, it feels like a talk. Behind the scenes, it is a list of messages. Each message has a role. The role tells the model who is speaking and how much weight to give the words. Both the Claude and OpenAI docs explain this idea. This lesson puts it in plain words.

The three main roles

  • System or developer: the rules of the app. Tone, goals, limits and things to avoid.
  • User: the person's request, or the material to work on.
  • Assistant: what the model said earlier in the chat.

The names differ a little. Claude calls the top rules the system prompt. OpenAI calls them developer messages, and also uses the older name system. The idea is the same.

Why roles matter

  • Rules in the top role win over requests in the user role. A shop bot told never to promise refunds should keep to that, even if a customer asks.
  • Keeping rules and data apart reduces mix-ups. The model can tell what is an instruction and what is just text to read.
  • Rules stay the same while user messages change. That makes them easy to reuse, test and save money on later.

The model has no memory by itself

Each request is fresh. The model only sees the messages you send. To continue a chat, the app sends the whole history again. This is why long chats get slower and cost more. It is also why a new chat starts blank.

Some products add memory on top. Those are extras that the app builds. They are not part of the model.

a-chat-as-a-list.txt
system:    You are a support helper for a shoe shop. Be kind and short.
           Never promise a refund. Send refund questions to a person.
user:      Where is my order?
assistant: I can help. What is your order number?
user:      SH-1042

What goes where

  • Top rules: who the model is, the goal, the tone, the limits and the format of the answer.
  • User message: the task and the material, such as a customer email to answer.
  • Assistant messages: earlier replies. You can also write a few good example replies here to show the style you want.

A simple layout for the top rules

The OpenAI docs suggest four parts. They fit Claude too. Use clear headings so the model can find each part.

  • Identity: the role and the goal.
  • Instructions: the rules, in short sentences.
  • Examples: one to three samples of a good answer.
  • Context: facts the model needs, such as a price list.
→Write rules the way you would brief a new colleague. Plain sentences work better than clever tricks.
⚠Never put passwords or keys in the rules. People can sometimes trick a model into repeating them. Keep secrets in your own code.
Key takeaways
  • ✓A chat is a list of messages, and each message has a role.
  • ✓The top role holds the rules. The user role holds the request and the material.
  • ✓The model remembers nothing on its own, so the app resends the history each time.
  • ✓Lay out the rules in four parts: identity, instructions, examples and context.
  • ✓Keep secrets out of every prompt.
Hands-on exercise

Write a top-rules message

  1. Pick a small job, such as answering questions for a local gym.
  2. Write the four parts: identity, instructions, one example answer and the facts it needs.
  3. Paste it into a chat tool as the first message, then ask three real questions.
  4. Change one rule and ask the same questions again. Note what changed.
Check yourself
Q1Why does a long chat get slower and cost more?show answer

The app sends the whole history with every request. More text means more to process.

Q2Where should a shop's no-refund rule go?show answer

In the top role, such as the system prompt or developer message. Rules there win over user requests.

Q3Does the model remember last week's chat?show answer

No. The model only sees what is sent. Any memory is a feature the app adds on top.

The Prompting Playbook, Straight from the Docs →
0 / 11 finished0%