Conversational Patterns & Agentic Tools
Multi-turn memory, instruction persistence and safe tools.
The Stateless Truth
Scenario 7 of the exam is Conversational AI Architecture Patterns. The first thing it tests is whether you understand that the Claude API is stateless: the model keeps no memory between requests.
Every turn you send the full message history in the messages array. "Memory" in a conversational app is something you engineer client-side, not a server session the model holds for you.
systemcarries persistent instructionsmessagescarries the entire turn-by-turn history, every request
import anthropic
client = anthropic.Anthropic()
# Memory = the list YOU maintain and resend each turn
history = [
{"role": "user", "content": "My order id is 8842."},
{"role": "assistant", "content": "Got it, order 8842."},
{"role": "user", "content": "When does it ship?"},
]
resp = client.messages.create(
model="claude-sonnet-4-5",
max_tokens=1024,
system="You are a concise support agent.",
messages=history, # FULL history, every single turn
)Instruction Persistence Lives in system
In multi-turn chat, instructions that must hold for the entire session belong in the system field, not buried in a user turn 20 messages ago.
Why this matters: models exhibit lost-in-the-middle behavior, attending more to the start and end of the context than the middle. An instruction wedged in turn 7 of a 40-turn chat is the easiest thing for the model to drift away from.
The system prompt is re-supplied verbatim on every request, so it is the most reliable home for persistent rules: tone, role, refusal policy, output constraints.
All lessons in this course
- Support Agent & Multi-Agent Research
- Code Gen & Developer Productivity
- CI/CD & Structured Extraction
- Conversational Patterns & Agentic Tools