C.W.K.
Stream
Lesson 05 of 05 · published

Role Discipline: System, User, Assistant

~22 min · roles, system-prompt, discipline

Level 0Window Watcher
0 XP0/50 lessons0/13 achievements
0/100 XP to next level100 XP to go0% complete

Roles are not just decoration

Most chat APIs distinguish system, user, and assistant messages. The system message carries the most authority and is the natural home for the spine. User messages carry tasks. Assistant messages carry replies. Mixing them — putting tool schemas in a user message, putting rules in an assistant message, dumping a long history into a single user message — diffuses authority and confuses cache.

Multi-turn fidelity

When you replay history across turns, preserve role assignments faithfully. Squashing the entire conversation into one giant user message saves no money and breaks the model's ability to track who said what. Modern APIs charge per token, not per message, so the only cost of preserving roles is structural cleanliness.

One role per concept

System for rules. User for tasks. Assistant for replies. Tool messages for tool results. If a 'role' field exists in the API, it is doing work — use it as designed.

Code

Clean role layout·python
messages = [
  {"role": "system", "content": SPINE},
  {"role": "user", "content": prior_user_1},
  {"role": "assistant", "content": prior_assistant_1},
  {"role": "user", "content": prior_user_2},
  {"role": "assistant", "content": prior_assistant_2},
  {"role": "user", "content": current_question},
]
Anti-pattern: squashed history·python
# DO NOT DO THIS
messages = [
  {"role": "system", "content": SPINE},
  {"role": "user", "content":
      "Earlier I said X. You replied Y. Then I said Z. Now I want W."},
]
# Squashing kills role-aware attention and breaks cache structure.

External links

Exercise

Audit one of your message-construction loops. Confirm that system holds the spine, user holds tasks, assistant holds prior replies, and tool messages carry tool results. Fix anything that is squashed.
Hint
If you see the string 'Earlier I said' inside a user message, you have a squashing bug.

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.