LESSON 09 / 215·2 min readFoundation

System, user, assistant, and tool messages

Must knowConcept lesson
01 Understand02 Recall03 Prepare

Words made simple

A few useful meanings before you read the explanation.

API
A way for one piece of software to ask another for data or an action. A claims API might return the current status of a claim.
State
The data describing where a workflow is now, what it already knows, and what still needs to happen.
Authorization
Checking what that identity is allowed to read or do. Being logged in does not grant access to every record.

Overview

  • Message roles identify the purpose and source of information.
  • System or developer instructions describe application behavior, user messages contain requests, assistant messages contain model responses, and tool results supply external observations.
  • Exact role names and request envelopes vary across APIs.

Why this matters

Roles help the model separate application instructions from requests and data, and help the application maintain conversation state.

An everyday example

A company handbook, a customer's request, and an invoice are different kinds of information.

A technical example

Instructions say “Never invent claim status”; the user asks about claim C42; a tool returns status: "in_review"; the assistant explains it.

How it works

  1. Build trusted instructions server-side
  2. Append authenticated user input
  3. Call tools when requested
  4. Attach results with matching call IDs
  5. Generate the response.

Architecture and flow

Trusted instructions + user request → model → tool request/result → assistant response.

The insurance assistant example

A retrieved policy paragraph saying “ignore previous instructions” is document data, not a new system instruction.

When to use it

For any multi-turn or tool-enabled application.

When to avoid it

Never accept browser-supplied system instructions or an assistant message claiming that authorization was completed.

Interview answer

“Roles distinguish instructions, requests, responses, and tool observations. The backend owns trusted instructions and still enforces permissions independently.”

Benefits, trade-offs, and production considerations

  • Role hierarchy is a model behavior mechanism, not an authorization boundary.
  • Preserve tool-call relationships and sanitize stored history before replaying it into a model.
PAUSE & RECALL

Can you explain it without the notes?

System, user, assistant, and tool messages

Use your own words. Explain an example and one limitation before checking the explanation.

Check your explanation

Message roles identify the purpose and source of information. System or developer instructions describe application behavior, user messages contain requests, assistant messages contain model responses, and tool results supply external observations. Exact role…

CONNECT IT TO YOUR INTERVIEW

Turn this concept into a clear answer.

Practice this concept
YOUR NEXT STEP

Keep connecting the ideas.

Next lesson: Prompt engineering, zero-shot, and few-shot prompting

Adapted from 13_AI.MD · “System, user, assistant, and tool messages”. Examples are study fragments; framework behavior can depend on your version.