Skip to content

Dynamic References

Many step fields take a reference string that CARL resolves against the execution context at run time. This is how a later step reads an earlier step’s output, a memory value, or the original input.

ReferenceResolves to
$history[-1]The output of a previous step by index (negative indexes from the end).
$historyThe full current history as a single string.
$memory.namespace.keyA value from memory in a namespace. $memory.key uses the default namespace.
$outer_contextThe original input. If it looks like JSON, it’s parsed automatically.
$metadata.pathA (possibly nested) value from context metadata.
$steps.pathA nested value from the per-step results metadata.
$ltm.keyA value from long-term memory (when an LTM backend is wired in).
$event.nameThe most-recent payload emitted for an event (see event-driven steps).
"literal" or 'literal'A quoted string is returned verbatim (a literal, not a reference).

Anything else is looked up as a plain key in context metadata.

FieldOn stepTypical value
input_mappingTool{"data": "$history[-1]"}
argument_mappingMCP{"query": "$memory.input.query"}
value_sourceMemory (write/append)"$history[-1]"
conditionConditional branch"$history[-1] == 'yes'"
condition_context_keyConditional"$history[-1]"
condition_keyLoop"$memory.loop.needs_retry"
input_sourceStructured output"$history[-1]"
input_keyTransform"$history[-1]"
from mmar_carl import ToolStepDescription, ToolStepConfig
# Feed the previous step's output and a literal into a tool
ToolStepDescription(
number=2,
title="Summarise",
dependencies=[1],
config=ToolStepConfig(
tool_name="summarise",
input_mapping={
"text": "$history[-1]",
"topic": "$memory.input.topic",
"style": "'concise'", # a literal string
},
),
)