Stale Context & Starting Fresh
When resumed tool results are outdated, summarize anew.
Resuming a Session
Claude Code lets you continue work across days. --resume <name> reopens a named session with its full message history intact: the prompts, the model's reasoning, and crucially the tool results that were captured the first time.
That replay is powerful. But it hides a sharp edge: those tool results are a snapshot of the past, not a live view of your system. This lesson is about recognizing when that snapshot has gone stale and what to do instead.
claude --resume refactor-authWhy the History Is Frozen
Remember how the API works: the model keeps no state of its own. Every turn you send the full messages history — including prior tool_result blocks. The model reasons over whatever those blocks say.
A resumed session simply reloads that saved history. If a Read captured a file's contents last Tuesday, the model still believes Tuesday's version today — even if the file changed ten times since.
messages = [
{"role": "user", "content": "Refactor the auth module"},
{"role": "assistant", "content": [tool_use_read_authpy]},
# tool_result below is a FROZEN snapshot from the prior session
{"role": "user", "content": [tool_result_authpy_old]},
]
client.messages.create(model="claude-opus-4-1", max_tokens=2048, messages=messages, tools=tools)All lessons in this course
- Fixed Pipelines vs Adaptive Decomposition
- Multi-Pass Decomposition
- Session Management
- Stale Context & Starting Fresh