Part 14 / Topic 2 of 7
Multi-turn conversations
The API is stateless: it remembers nothing between calls. A conversation is you resending the whole history every turn:
# examples/04_multi_turn_the_api_is_stateless.py (ran against the local mock)
history.append({"role": "user", "content": user_text})
response = client.messages.create(model="claude-opus-5-5", max_tokens=16000, messages=history)
history.append({"role": "assistant", "content": response.content}) # keep full blocks
# messages sent on turn 2: 3
# roles: ['user', 'assistant', 'user', 'assistant']
Keep the assistant's full content blocks in history (not just extracted text) — tool-use turns depend on it (Part 18). And remember Part 13: history grows, and you pay for all of it each turn; long chats need summarisation or truncation strategies.
Done here? The practice set for Part 14 — 4 exercises with solutions — is on the part page.