Prompts, messages and roles

AI & LLM fundamentals · Essentials · 9 min

Every chat app, API and automation tool organises input this way, so the roles tell you where each kind of text belongs.

The prompt is everything you send to the model. In chat-style models the prompt is not one block of text but a list of messages, and each message has a role saying who it comes from:

  • system: background instructions from whoever built the app, such as "You are a support assistant for Acme. Answer briefly." Some providers call this the developer message or simply "instructions". It is followed with more weight than ordinary messages.
  • user: what the person (or your automation) asks.
  • assistant: what the model answered earlier.

An important surprise: the model has no memory between requests. Each time, the app sends the whole conversation so far, and the model reads it from the top to write the next assistant message. When a chat app "remembers" what you said ten messages ago, it is because it resent those messages. When a conversation gets very long, apps have to drop or shorten older messages.

This explains several things you will notice:

  • Starting a new chat gives a clean slate.
  • In an automation tool, each AI step usually starts fresh unless you pass earlier text into it yourself.
  • Long conversations cost more and get slower, because all earlier messages are sent (and paid for) again each time.

In Zapier, Gumloop and similar tools, the "instructions" or "system prompt" box fills the system role, and the "prompt" or "input" box fills the user role. When you call a model from code, you send the list of messages yourself, as shown in the example.

Example

[
  {"role": "system",    "content": "You are a friendly travel helper. Answer in two sentences."},
  {"role": "user",      "content": "Is May a good time to visit Lisbon?"},
  {"role": "assistant", "content": "Yes, May is warm and less crowded than summer. Book early for festivals."},
  {"role": "user",      "content": "And what should I pack?"}
]

Remember

  • A prompt is a list of messages with roles: system, user, assistant
  • The model is stateless: the whole conversation is resent every turn
  • System or developer instructions carry more weight than user messages

Check yourself

  1. A chatbot seems to 'remember' your name from earlier in the chat. How?

Sign in to answer, see the explanations, and get this lesson back as a quick review later.

Official docs: developers.openai.com/api/docs/guides/text