Skip to content

Subagent Recipes

Standard subagent recipes for common default rosters.

Factories, not module-level constants: a SubAgentSpec wraps an LLMAgentBuilder recipe, which needs an LLM — there is no zero-config answer the way DEFAULT_TOOLS is for tools. Roster is general + explore, the intersection of the subagent rosters shipped by other harnesses (a full-tools generalist and a read-only, cheap-to-run lookup agent).

general_subagent

general_subagent(
    llm,
    name=GENERAL_NAME,
    max_steps=GENERAL_MAX_STEPS,
    memories=None,
)

Return a general-purpose subagent spec.

Equipped with DEFAULT_TOOLS. Suited to open-ended, multi-step, context-heavy side work — the same profile as the coordinator minus the dispatch tool (depth 1) and a disposable per-dispatch context.

Parameters:

Name Type Description Default
llm LLM

Backbone LLM for the subagent.

required
name str

Registry key / dispatch enum value. Defaults to GENERAL_NAME.

GENERAL_NAME
max_steps int

Cap on steps per dispatch. Defaults to GENERAL_MAX_STEPS.

GENERAL_MAX_STEPS
memories list[Memory] | None

Memory backends for the subagent. Defaults to None.

None

Returns:

Name Type Description
SubAgentSpec SubAgentSpec

A spec wrapping a DEFAULT_TOOLS-equipped builder.

Source code in src/llm_agents_from_scratch/subagents/recipes.py
def general_subagent(
    llm: LLM,
    name: str = GENERAL_NAME,
    max_steps: int = GENERAL_MAX_STEPS,
    memories: list[Memory] | None = None,
) -> SubAgentSpec:
    """Return a general-purpose subagent spec.

    Equipped with ``DEFAULT_TOOLS``. Suited to open-ended, multi-step,
    context-heavy side work — the same profile as the coordinator minus
    the dispatch tool (depth 1) and a disposable per-dispatch context.

    Args:
        llm (LLM): Backbone LLM for the subagent.
        name (str, optional): Registry key / dispatch enum value.
            Defaults to `GENERAL_NAME`.
        max_steps (int, optional): Cap on steps per dispatch. Defaults
            to `GENERAL_MAX_STEPS`.
        memories (list[Memory] | None, optional): Memory backends for
            the subagent. Defaults to None.

    Returns:
        SubAgentSpec: A spec wrapping a `DEFAULT_TOOLS`-equipped builder.
    """
    return SubAgentSpec(
        name=name,
        description=(
            "General-purpose subagent for open-ended research, "
            "multi-step tasks, or work that benefits from an isolated "
            "context. Equipped with file reading and Python execution."
        ),
        builder=LLMAgentBuilder(
            llm=llm,
            tools=DEFAULT_TOOLS,
            memories=memories,
        ),
        max_steps=max_steps,
    )

explore_subagent

explore_subagent(
    llm,
    name=EXPLORE_NAME,
    max_steps=EXPLORE_MAX_STEPS,
    memories=None,
)

Return a read-only, lookup-tuned subagent spec.

Equipped with only ReadFileTool — read-only by construction: the tool subset itself is the permission boundary, no separate permission system required. A cheap, fast option for lookups, well suited to a smaller model than the coordinator.

Parameters:

Name Type Description Default
llm LLM

Backbone LLM for the subagent.

required
name str

Registry key / dispatch enum value. Defaults to EXPLORE_NAME.

EXPLORE_NAME
max_steps int

Cap on steps per dispatch. Lower than general_subagent's default since lookups need fewer steps. Defaults to EXPLORE_MAX_STEPS.

EXPLORE_MAX_STEPS
memories list[Memory] | None

Memory backends for the subagent. Defaults to None.

None

Returns:

Name Type Description
SubAgentSpec SubAgentSpec

A spec wrapping a ReadFileTool-only builder.

Source code in src/llm_agents_from_scratch/subagents/recipes.py
def explore_subagent(
    llm: LLM,
    name: str = EXPLORE_NAME,
    max_steps: int = EXPLORE_MAX_STEPS,
    memories: list[Memory] | None = None,
) -> SubAgentSpec:
    """Return a read-only, lookup-tuned subagent spec.

    Equipped with only ``ReadFileTool`` — read-only by construction:
    the tool subset itself is the permission boundary, no separate
    permission system required. A cheap, fast option for lookups,
    well suited to a smaller model than the coordinator.

    Args:
        llm (LLM): Backbone LLM for the subagent.
        name (str, optional): Registry key / dispatch enum value.
            Defaults to `EXPLORE_NAME`.
        max_steps (int, optional): Cap on steps per dispatch. Lower
            than `general_subagent`'s default since lookups need
            fewer steps. Defaults to `EXPLORE_MAX_STEPS`.
        memories (list[Memory] | None, optional): Memory backends for
            the subagent. Defaults to None.

    Returns:
        SubAgentSpec: A spec wrapping a `ReadFileTool`-only builder.
    """
    return SubAgentSpec(
        name=name,
        description=(
            "Read-only subagent for quickly finding and reading files. "
            "Use for lookups and fact-finding, not multi-step work."
        ),
        builder=LLMAgentBuilder(
            llm=llm,
            tools=[ReadFileTool()],
            memories=memories,
        ),
        max_steps=max_steps,
    )