Short-Term Conversation Memory › The Problem: Stateless Interactions
Michael BrenndoerferJuly 1, 20252 min read
AI Agent HandbookAll chapters Part 6 of 15Memory and Retrieval - How Agents Remember
Short-Term Conversation Memory › The Problem: Stateless InteractionsOne section · Sections in this chapter2 / 15 ↓
Sections in this chapter15
Let's see what happens without memory. Here's a conversation with our agent:
User: What's the capital of France?
Agent: The capital of France is Paris.
User: What's the population?
Agent: I need more context. What location are you asking about?The agent answered the first question perfectly. But when you asked a follow-up ("What's the population?"), it had no memory of discussing France. Each interaction is isolated, like talking to someone with amnesia.
This breaks down quickly in real conversations. People naturally ask follow-up questions, refer to previous topics, and build on earlier context. Without memory, your agent can't handle these basic conversational patterns.
Example (Claude Sonnet 4.5)
Let's see this in code:
In[3]:
Codeimport os
from anthropic import Anthropic
## Using Claude Sonnet 4.5 for its excellent conversational capabilities
client = Anthropic(api_key=os.getenv("ANTHROPIC_API_KEY"))
def ask_without_memory(question: str) -> str:
"""Ask a question without any conversation history."""
response = client.messages.create(
model="claude-sonnet-4-5",
max_tokens=1024,
messages=[
{"role": "user", "content": question}
]
)
return response.content[0].text
## First question
print("Q1:", ask_without_memory("What's the capital of France?"))
## Output: "The capital of France is Paris."
## Follow-up question
print("Q2:", ask_without_memory("What's the population?"))
## Output: "I'd be happy to help with population information,
## but I need to know which location you're asking about."Out[3]:
ConsoleQ1: The capital of France is Paris.
Q2: I'd be happy to help you with population information! Could you please specify which location you're asking about? For example: - A specific city? - A country? - The world? - Some other area?
Each call to ask_without_memory creates a fresh conversation. The agent has no context from previous questions. This is the default behavior when you don't explicitly manage conversation history.