Skip to content

ReasoningChain

ReasoningChain is the main public API: a list of steps plus execution settings. It runs them through the DAG executor and serialises to JSON for reuse.

ReasoningChain(steps, max_workers=3, ...)
ParameterTypeDefaultPurpose
stepsSequence[StepDescription...]— (required)The steps to run.
max_workersint | str3Parallel worker pool size. "auto" sizes it for you.
enable_progressboolFalseEmit progress logging.
search_configContextSearchConfig | NoneNoneContext-extraction strategy (substring / vector).
metricslist[MetricBase][]Chain-level metrics.
timeoutfloat | NoneNoneChain-level timeout in seconds.
replan_policyReplanPolicy | NoneNoneRE-PLAN policy.
default_llm_configLLMStepConfig | NoneNoneDefault LLM config for all LLM steps.
memory_schemadict | NoneNoneWrite-time memory validation schema.
metadatadict | NoneNoneArbitrary metadata stored on the chain.

(Also: prompt_template, trace_name, session_id, step_groups, max_injections.)

result = chain.execute(context) # synchronous
result = await chain.execute_async(context) # async

For step-by-step streaming, use stream_async. See async execution for parallelism, callbacks, and timeouts.

Chains round-trip to JSON so you can save and reload them:

chain.save("my_chain.json") # write to disk
loaded = ReasoningChain.load("my_chain.json")
d = chain.to_dict(); ReasoningChain.from_dict(d)
s = chain.to_json(); ReasoningChain.from_json(s)

from_dict runs full validation (cycles, dependency references, reference-syntax warnings).

  • chain.estimate_cost(pricing=...) — dry-run token/USD projection before running.
  • chain.to_mermaid() — render the DAG as a Mermaid diagram.
  • chain.reflect(...) — analyse a completed run.