Agent memory is modelled in src/smolagents/memory.py as a typed step list on AgentMemory. Step types form a hierarchy:
SystemPromptStep— the initial system promptTaskStep— the user task, with optional attached imagesPlanningStep— an optional planning message produced atplanning_intervalActionStep— one ReAct cycle: model input messages, code/tool call, observations, error, token usage, and step timingFinalAnswerStep— the terminal step holding the agent's answer
Each step implements to_messages(summary_mode: bool) which renders it as a list of ChatMessage dicts suitable for the next LLM call. summary_mode=True is used during planning updates to strip previous plan messages and shrink context.
Step callbacks are registered via CallbackRegistry and are dispatched per step type; this is the integration point for custom logging, evaluation harnesses, or live UI updates.
src/smolagents/memory.pysrc/smolagents/agents.py