Flow controls
← Relifold documentation

Unfold

Apply a transformation recursively under explicit stopping bounds.

Unfold repeatedly applies one deterministic or semantic Transform to generated values in the same Space. Use it for bounded recursive expansion, not for an ordinary linear pipeline.

expand = SemTransform(
    name="expand-topic",
    input_spaces=("topics",),
    output_space="topics",
    primary_key="topic",
    prompt=(
        "Return the immediate subtopics as children. Return an empty list when "
        "the topic should not be divided further."
    ),
    emits=("children",),
    provider="openai",
    model="gpt-5",
    reasoning_effort="low",
)

Unfold(
    name="expand-topic-tree",
    body=expand,
    emits="list",
    field="children",
    stop=Stop(max_depth=4, max_nodes=500),
)
ParameterDefaultMeaning
bodyrequiredA Transform or SemTransform whose input and output Space match.
emitslistWhether each expansion returns a list or one next value.
fieldchildren / nextThe output field containing generated values.
stop.sentinelnoneOptional leaf token that ends one branch.
stop.max_depth10Maximum recursive depth.
stop.max_nodesunlimitedMaximum generated values across the expansion.

Bound recursive work

Always choose depth and node limits that match the expected output. These limits protect the session from an unexpectedly expansive transformation and make cost expectations reviewable.