Agent run memory, replay, and message reconstruction
What this workflow does
Agent task/action/planning history is stored in AgentMemory, converted back into messages, replayed to logs, and can yield concatenated code actions.
Purpose
Persist and inspect an agent's step-by-step work product
What it produces
AgentMemory / step history
Who relies on it
Agent developer or operator
Why this workflow matters
- Enables debugging and auditability of agent runs
- Preserves task, planning, tool-call, and final-answer context for later inspection
- Supports reconstruction of executable code from prior actions
Implementation references
- AgentMemory src/smolagents/memory.py · lines 214–277
- ActionStep src/smolagents/memory.py · lines 50–150
- AgentMemory.return_full_code() src/smolagents/memory.py · lines 273–277
- MemoryStep src/smolagents/memory.py · lines 41–47
- AgentMemory.replay() src/smolagents/memory.py · lines 248–271
- ActionStep.to_messages() src/smolagents/memory.py · lines 92–150
- PlanningStep.to_messages() src/smolagents/memory.py · lines 174–183
- TestAgentMemory.test_initialization() tests/test_memory.py · lines 21–25
- TestAgentMemory.test_return_all_code_actions() tests/test_memory.py · lines 27–34
- test_action_step_to_messages_no_tool_calls_with_observations() tests/test_memory.py · lines 159–177
- test_action_step_to_messages() tests/test_memory.py · lines 119–156
- PlanningStep src/smolagents/memory.py · lines 153–183