SubAgentSpec¶
SubAgentSpec — specification for a named subagent.
SubAgentSpec
¶
Specification for a named subagent in a multi-agent system.
Each SubAgentSpec entry registers a build recipe for a subagent
under a human-readable name. The name serves as the registry key on
the parent coordinator and as the enum value the coordinator's
UseSubAgentTool presents to the LLM for dispatch.
The spec is pure data: it never constructs or holds a live agent.
UseSubAgentTool builds a fresh LLMAgent from builder on
every dispatch. Whatever the builder was given directly (an
LLM, Memory stores, MCPToolProvider instances) is reused
as-is across builds — only the LLMAgent shell itself is rebuilt
each time, mirroring the existing fresh-TaskHandler-per-run()
pattern.
A plain class, not a pydantic BaseModel, for the same reason
Skill/Memory/LLMAgentBuilder are plain classes: those
are reserved for behavior-bearing objects that wrap a live
collaborator, not passive serializable data. BaseModel would
only have bought required-field validation (a plain __init__
already raises TypeError on missing required args) at the cost
of needing arbitrary_types_allowed=True for builder, a
non-pydantic type.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
Unique registry key for this subagent. Appears as an enum
value in |
|
description |
Short routing signal shown to the coordinator LLM in
the |
|
builder |
The recipe used to build this subagent fresh on every dispatch. |
|
max_steps |
Optional cap on the number of steps the subagent may
take per dispatch. Passed to |
|
skills_scopes |
Optional scopes to scan for skills on this
subagent's dispatches. Passed to |
|
explicit_only_skills |
Optional skill names to exclude from this
subagent's model catalog on dispatch. Passed to
|
Source code in src/llm_agents_from_scratch/subagents/spec.py
__init__
¶
__init__(
name,
description,
builder,
max_steps=None,
skills_scopes=None,
explicit_only_skills=None,
)
Initialize a SubAgentSpec.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Unique registry key for this subagent. |
required |
description
|
str
|
Routing signal shown to the coordinator LLM in
the |
required |
builder
|
LLMAgentBuilder
|
The recipe used to build this subagent per dispatch. |
required |
max_steps
|
int | None
|
Optional cap on subagent steps per dispatch.
Defaults to |
None
|
skills_scopes
|
list[SkillScope] | None
|
Optional scopes to scan for skills on this
subagent's dispatches. Defaults to |
None
|
explicit_only_skills
|
set[str] | None
|
Optional skill names to exclude from
this subagent's model catalog on dispatch. Defaults to
|
None
|
Source code in src/llm_agents_from_scratch/subagents/spec.py
__repr__
¶
Readable repr listing every field.
Source code in src/llm_agents_from_scratch/subagents/spec.py
catalog
¶
Return XML entry for this spec in the subagents catalog.