Skip to content

Memory Step

MemoryStepDescription performs an operation on the context’s namespaced memory store — useful for stashing intermediate results that later steps read back.

FieldTypeDefaultPurpose
operationMemoryOperation— (required)read / write / append / delete / list.
memory_keystr— (required)Key in the memory store.
value_sourcestr | NoneNoneWhere the value comes from on write/append (e.g. "$history[-1]").
default_valueAnyNoneReturned on read when the key is missing.
namespacestr"default"Namespace for isolation.

Memory is organised by namespace → key. Read it back elsewhere with the $memory.namespace.key reference.

from mmar_carl import MemoryStepDescription, MemoryStepConfig, MemoryOperation
# Step 3 stores step 2's output under results/analysis
MemoryStepDescription(
number=3,
title="Store result",
dependencies=[2],
config=MemoryStepConfig(
operation=MemoryOperation.WRITE,
memory_key="analysis",
value_source="$history[-1]",
namespace="results",
),
)
# A later step reads it back
MemoryStepDescription(
number=5,
title="Retrieve result",
config=MemoryStepConfig(
operation=MemoryOperation.READ,
memory_key="analysis",
namespace="results",
default_value="(missing)",
),
)