Skip to content

Steps Overview

A CARL chain is a list of steps. Each step is a typed description object that declares what to do and what it depends on. The DAG executor picks an executor by the step’s type.

Use the typed classes (LLMStepDescription, ToolStepDescription, …) for new code. They give you type-checked fields and clear intent. The legacy unified StepDescription class is still accepted for backward compatibility; convert it with legacy_step.to_typed_step().

To load saved JSON into typed classes, use ReasoningChain.from_dict_typed(data). from_dict(), from_json() and load() keep the legacy path by default (see ReasoningChain).

All step classes extend StepDescriptionBase and inherit these fields:

FieldTypeDefaultPurpose
numberintrequiredStep number in the sequence.
titlestrrequiredHuman-readable title.
dependencieslist[int][]Step numbers this step waits for.
triggered_bylist[str][]Event names that gate this step (see the event bus). The step is ready only when all listed events have fired and numeric dependencies are met.
checkpointboolFalseMark as a RE-PLAN rollback checkpoint.
checkpoint_namestr | NoneNoneOptional checkpoint label.
replan_enabledbool | NoneNonePer-step RE-PLAN override (None = use the chain policy).
frozenboolFalseEvolution helpers must not change, retype or delete this step. Honoured by the mmar_carl.meta mutation helpers, not by ChainMutator (see EvoC primitives).
metadatadict{}Free-form step metadata; the executor records provenance here.
metricslist[MetricBase][]Metrics evaluated after the step runs.
loop_back_toint | NoneNoneStep to loop back to. See loops.
loop_configLoopConfig | NoneNoneLoop condition and budget guard.
cacheStepCache | NoneNoneResult memoization. See caching. command, shell_session, command_plan, planner, claude_code and codex reject it.

StepType has 29 values in 0.5.2. "bash" from old chain JSON still loads as command. New since 0.4.0: claude_code, codex, selection and planner (0.5.0), decision (0.5.1) and terminate (0.5.2).

TypeClassWhat it does
llmLLMStepDescriptionChain-of-thought reasoning with one LLM call (the default).
structured_outputStructuredOutputStepDescriptionLLM output validated against a JSON Schema.
toolToolStepDescriptionCalls a registered Python function.
memoryMemoryStepDescriptionread / write / append / delete / list on shared memory.
transformTransformStepDescriptionData transforms with no LLM call.
conditionalConditionalStepDescriptionRoutes to one branch; the others are skipped.
tool_discoveryToolDiscoveryStepDescriptionDiscovers and registers tools at runtime.
evaluationEvaluationStepDescriptionInline quality gate on another step’s output. See metrics.
selectionSelectionStepDescriptionPicks items from a list (top-k, weighted, random, filter) with no LLM call.
decisionDecisionStepDescriptionAsks a decision model typed questions (predicate, choice, score) through a host-granted endpoint.
TypeClassWhat it does
agentAgentStepDescriptionBounded ReAct loop over an explicit list of registered tools, with a required finish.
plannerPlannerStepDescriptionA model picks and orders tool actions the chain declared; they run as injected tool steps.
claude_codeClaudeCodeStepDescriptionHands a whole subtask to a headless Claude Code CLI agent.
codexCodexStepDescriptionHands a whole subtask to a local Codex agent through the Codex SDK.
agent_skillAgentSkillStepDescriptionRuns an AgentSkill folder.
agent_handoffAgentHandoffStepDescriptionDelegates to a complete sub-chain. See handoff.
supervisorSupervisorStepDescriptionAn LLM routes the task to one of N sub-chains. See supervisor.
debateDebateStepDescriptionRound-robin multi-role debate and a judge. See debate.
parallel_samplingParallelSamplingStepDescriptionSamples N answers, then votes or judges. See parallel sampling.
human_inputHumanInputStepDescriptionAsks a human through a host callback, with a typed outcome. See human-in-the-loop.

A chain can also expose another chain as a callable tool. That is not a step type; it is the top-level chain_tools field. See chain tools.

TypeClassWhat it does
codeCodeStepDescriptionRuns one exact Python source string in a strictly isolated host runtime.
commandCommandStepDescriptionRuns one argv command through a skill runtime under a host CommandPolicy.
command_planCommandPlanStepDescriptionAn LLM picks typed arguments for a host-registered command capability.
shell_sessionShellSessionStepDescriptionRuns a static script in one shell process.
waitWaitStepDescriptionWaits for a timer, an absolute time, or a named event.
mapMapStepDescriptionBounded ordered fan-out of one tool over a JSON array.
terminateTerminateStepDescriptionReturns an explicit answer and stops the chain after the current batch.
TypeClassWhat it does
mcpMCPStepDescriptionCalls a tool on an MCP server. See MCP.
mcp_resourceMCPResourceStepDescriptionReads a named MCP resource into memory. See MCP resources.

Steps that run code, commands or agents follow one rule: a serialized chain is input, never authority. The chain says what it wants. The host grants permission at run time through objects that are never written to chain JSON: CommandPolicy, CommandCapabilityRegistry, CodeExecutionPolicy, the network enforcer, the human-input provider, registered tools, and two context fields:

  • ReasoningContext.allow_local_agent_execution (default False) must be True before a claude_code or codex step may start a local agent. Loading a chain never grants it.
  • ReasoningContext.decision_endpoints authorizes the exact URL and key variable for each decision provider.

The claude_code step still serializes its CLI flags (permission_mode, allowed_tools, extra_cli_args, add_dirs), so a chain can ask for broad agent permissions. Its env overrides are runtime-only and never written to JSON. The codex step limits the sandbox to read-only or workspace-write. Review chains with these steps before you grant local agent execution.

chain.preflight(context) lists what a chain needs and what is missing: tools, MCP servers, skills, code profiles, Claude Code CLIs, the Codex runtime and decision-model credentials. See preflight.

  • Loops: re-run a range of steps until a condition holds.
  • Caching: memoize a step’s result within a run.
  • Dynamic references: $history, $memory, $outer_context, $steps and more wire steps together.
  • Run controls: fail-fast, pause, resume, cancel and timeouts.