A single agent with many tools quickly becomes a monolith. Motus gives you two primitives for breaking it apart:Documentation Index
Fetch the complete documentation index at: https://docs.motus.lithosai.com/llms.txt
Use this file to discover all available pages before exploring further.
agent.as_tool()turns a specialist agent into a tool that a supervisor can call.agent.fork()makes an independent copy of an agent at its current conversation state so you can explore branches without touching the original.
Agent as tool
as_tool() is the core building block for supervisor and specialist patterns. Wrap any agent and hand the result to another agent’s tools=[...] list.
request: str. When the LLM decides to call it, Motus forwards the string to the specialist, runs the specialist’s full agent loop, and returns the result to the supervisor as if it were any other tool output.
Parameter reference
All parameters are keyword-only.| Parameter | Type | Default | Description |
|---|---|---|---|
name | str | None | the agent’s name | Tool name exposed to the supervisor. Override when the supervisor needs a clearer verb (e.g. "research" instead of "researcher"). |
description | str | None | "Delegate to sub-agent: <name>" | Tool description the supervisor’s LLM reads when deciding whether to call it. |
output_extractor | Callable | None | None | Post-process the specialist’s return value before it goes back to the supervisor. See Output extractors. |
stateful | bool | False | See Stateful vs. stateless. |
max_steps | int | None | the agent’s own max_steps | Override the specialist’s reasoning step cap for this tool. |
input_guardrails | list | None | None | Guardrails run on the request string before the specialist sees it. |
output_guardrails | list | None | None | Guardrails run on the specialist’s output before it returns to the supervisor. |
Stateful vs. stateless
Thestateful flag controls whether the specialist’s conversation history accumulates across tool calls within a single supervisor run.
- Stateless (default)
- Stateful
Each call forks the specialist, so every invocation starts from the specialist’s original state (system prompt plus any pre-loaded messages). The fork is a lightweight memory copy, not a model call. Concurrent invocations never share memory, which makes this safe for fan-out.
Output extractors
By default the specialist’s result is passed back as-is; non-string results are JSON-encoded before reaching the supervisor.output_extractor runs on the specialist’s return value first. Two common uses:
- Pull a field out of a structured result. If the specialist returns a Pydantic model, return just the field the supervisor actually needs.
- Shrink a long answer. The specialist may produce pages of analysis; the supervisor may only want the headline.
Errors
When the specialist raises, the exception is caught at the tool boundary and surfaced to the supervisor as a regular tool error ({"error": "..."}). The supervisor’s model sees the failure as feedback and can retry with a different input or give up, the same way it handles any other tool exception.
Forking
agent.fork() makes an independent copy of the agent with the same configuration and a forked copy of the conversation. Changes to the fork’s memory never affect the original.
__init__ argument (client, model, system prompt, tools, guardrails, response_format, reasoning, timeout, cache_policy, step_callback, and so on) and gets its own independent copy of the conversation memory.
Forking is useful for A/B comparisons, self-consistency sampling, and any case where you want to branch from a known conversation state without mutating the original. If you just want a fresh empty agent, instantiate a new ReActAgent rather than forking; fork’s job is preserving the accumulated conversation.
Where to go next
Agents
Everything a
ReActAgent can do on its own: tools, memory, guardrails, reasoning.Workflow
Deep dive on
@agent_task, the task graph, and parallel execution.Tools
How the
@tool decorator and guardrails work under the hood.Tracing
Debugging multi-agent flows is much easier with tracing on.

