Skip to content

Generate from a Description

ChainBuilder.from_description is a meta-agent: it asks an LLM to plan a chain of LLM / Tool / Memory / Transform / Conditional steps for a task, then parses the plan through ReasoningChain.from_dict so all the usual validation applies (cycle detection, dependency references, reference-syntax warnings).

from mmar_carl import ChainBuilder
chain = await ChainBuilder.from_description(
task="Outline the key arguments in the text, then condense them to 3 bullets.",
llm_client=client,
max_steps=4,
max_retries=2, # self-correct on validation errors
available_tools=["fetch", "summarise"],
)
ParameterTypeDefaultPurpose
taskstr— (required)Natural-language description of what the chain should do.
llm_clientAny— (required)Async client with get_response_with_retries(prompt, retries=…) or get_response(prompt).
available_skillslist[str] | NoneNoneSkill names surfaced in the planning prompt.
available_toolslist[str] | NoneNoneTool names the planner may reference (tool steps must use these).
max_stepsint10Upper bound on planned steps (raises ValueError if exceeded).
max_workersint | str"auto"Worker setting on the resulting chain.
extra_instructionsstr""Free-form text appended to the planning prompt.
max_retriesint2Self-correction rounds when the produced chain fails validation.

It’s an async classmethod — await it.

The full planner trail is written into chain.metadata for offline diagnosis: planner_prompt, planner_reply, and the per-attempt planner_attempts log (including validation errors that triggered a retry).