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

Role은 장식 아니야

대부분 chat API가 system, user, assistant message 구분. system message는 가장 큰 authority, spine의 자연 home. user는 task, assistant는 reply. 섞으면 — tool schema를 user에, rule을 assistant에, 긴 history를 single user message에 dump — authority 흩고 cache 헷갈려.

Multi-turn fidelity

turn 가로질러 history replay할 때 role assignment 충실히 보존. 전체 대화를 거대한 user message 하나로 squash하면 돈 안 아끼고 누가 뭘 말했는지 추적 능력만 망가져. modern API는 token 단위 과금이지 message 단위 아니야 — role 보존의 유일 비용은 구조적 청결.

concept당 role 하나

System은 rule. User는 task. Assistant는 reply. Tool message는 tool result. API에 'role' field 있으면 일하는 거 — API 설계대로 써.

Code

깨끗한 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

message 구성 loop 하나 audit. system이 spine, user가 task, assistant가 prior reply, tool message가 tool result 가지는지 확인. squashed 거 다 fix.
Hint
user message 안에 'Earlier I said' 문자열 보이면 squashing 버그.

Progress

Progress is local-only — sign in to sync across devices.
이 페이지에서 버그를 발견하셨거나 피드백이 있으세요?문제 신고

댓글 0

🔔 답글 알림 (로그인 필요)
로그인댓글을 남기려면 로그인해 주세요.

아직 댓글이 없어요. 첫 댓글을 남겨보세요.