Generate from a Description
ChainBuilder.from_description asks an LLM to plan a chain for a task, then
parses the plan through ReasoningChain.from_dict, so 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"],)It is an async classmethod.
What the planner can produce
Section titled “What the planner can produce”Since 0.5.0 the planning prompt is rendered from the live step catalog
(get_step_catalog().generation_prompt(...)), so it describes every
registered step type, with a compact card per type and the $... reference
grammar. available_tools and available_skills are listed for tool and
agent_skill steps. capability_library (a CapabilityLibrary) adds a
curated list of tools and skills to the prompt. MAESTRO does not use this
helper; it has its own generator.
Parameters
Section titled “Parameters”| Parameter | Type | Default | Purpose |
|---|---|---|---|
task | str | required | What the chain should do. |
llm_client | Any | required | An LLMClientBase, or any object with async get_response_with_retries(prompt, retries=…) or get_response(prompt). |
available_skills | list[str] | None | None | Skill names the planner may use in agent_skill steps. |
available_tools | list[str] | None | None | Tool names the planner is told to use in tool steps. |
capability_library | CapabilityLibrary | None | None | Extra tool and skill descriptions for the prompt (EvoC). |
max_steps | int | 10 | Upper bound on planned steps (ValueError if exceeded). |
max_workers | int | str | "auto" | Worker setting on the resulting chain. |
extra_instructions | str | "" | Free text appended to the planning prompt. |
max_retries | int | 2 | Self-correction rounds when the plan fails to parse or validate. |
The reply may be wrapped in a ```json fence; it is stripped.
Provenance
Section titled “Provenance”The planner trail is written into chain.metadata for offline diagnosis:
planner_prompt and planner_reply (both truncated), planner_attempts (one
entry per attempt with its prompt, reply and validation error), and
generated_from_description.
See also
Section titled “See also”- chain_from_description example in the repo.
- ChainBuilder · Preflight