Last lesson, a single message became a role block wrapped in special tokens. Real conversations are messier — many turns, tool calls, step-by-step reasoning. The trick: all of it folds back into that same stack of role blocks the model was trained on.
The model has no memory. Each turn, the whole conversation is re-sent as role blocks — stacked oldest to newest — and the model writes the next one.
system, user, or assistant — wrapped in the special tokens from the last lesson.assistant turn at the bottom .<|im_start|>role … <|im_end|> — the exact format the model was trained on. A whole conversation is just those blocks, in order.When the assistant needs live data, it writes a tool call instead of an answer. Your code runs the tool, and the result re-enters the stack as a new tool block — then the model reads everything again and answers.
tool role block.You can start the assistant's block for it. Pre-open the turn with a <think> tag and the model fills a private scratchpad — reasoning step by step — before it writes the answer.
<think> at its start and the model keeps going from there.<think> it reasons out loud — a scratchpad that's stripped away before you see the reply.The model reads this whole stack in a single pass — but how does it decide which earlier tokens matter for the next word? Next, attention: the step where every token weighs every other one.