Skip to content

Supervisor

SupervisorStepDescription asks an LLM to pick one specialist for the task, then runs that specialist’s sub-chain. Specialists are registered by name in the runtime-only agents field.

from mmar_carl import SupervisorStepDescription, SupervisorStepConfig
SupervisorStepDescription(
number=1,
title="Route to specialist",
agents={"pdf": pdf_chain, "search": search_chain, "code": code_chain},
config=SupervisorStepConfig(
routing_prompt=(
"Pick ONE specialist for the task. Reply with just the name.\n"
"Specialists: {agents}\n\nTask: {task}"
),
output_memory_key="specialist_result",
),
)

The routing_prompt can use {agents} (the available names) and {task} placeholders.

FieldPurpose
routing_promptPrompt the LLM uses to choose a specialist.
task_sourceReference for the task text (default $history[-1]).
fallback_agentAgent name to use if routing fails.
input_mappingInputs passed into the chosen sub-chain.
output_memory_key / output_namespaceWhere the result is stored.
propagate_failureWhether sub-chain failure fails this step.
inherit_toolsShare the parent’s registered tools with the sub-chain.
llm_configPer-step model override for the routing call.