Subagent
Beta
Server tools are currently in beta. The API and behavior may change.
The openrouter:subagent server tool lets a model delegate self-contained tasks to a smaller, cheaper, faster worker model mid-generation. When your model has a piece of work that doesn’t need its full capability — summarizing a document, extracting structured data, drafting boilerplate, reformatting text — it invokes the tool with a task_name and a task_description. The worker model executes the task and returns its result as the tool’s outcome, and your model continues, integrating the result.
The worker can be any OpenRouter model, and it can optionally run as a sub-agent with its own tools (for example openrouter:web_search). Each task is independent: the worker sees only the task description (not the parent conversation) and keeps no memory between tasks.
Quick start
Choosing the worker model
The worker model is resolved with the following precedence:
parameters.modelon the tool definition, if set.- The model from the outer API request, as a fallback.
Unlike the advisor tool, the delegating model does not choose its worker per call — the worker is fixed by the tool definition. The subagent tool itself can never be the worker model.
When does the model invoke it?
The tool’s description steers the model to delegate focused sub-tasks that don’t need its full capability — and to skip delegation for work that is faster to do directly than to describe. Because the worker has no access to the parent conversation, the model is instructed to include all relevant context and the expected output format in the task_description.
Parameters
Pass an optional parameters object on the tool entry:
Tool-call arguments
When invoking the tool, the model passes:
What the tool returns
On success the tool result contains the outcome text, the task name, and the model that produced it:
On failure the result has status: "error" with a message; the calling model continues without the outcome:
Worker tools
When you pass tools, the worker runs as an agentic sub-agent over them before producing its outcome — for example, giving the worker openrouter:web_search lets it ground its result in fresh sources. The worker’s tool use happens inside the tool call; only its final text is returned to your model.
Nested tools must be OpenRouter server tools (for example openrouter:web_search or openrouter:web_fetch). Function tools ({ "type": "function" }) are rejected with a 400: the worker call has no client-side executor, so a function tool call could never be fulfilled.
Recursion protection
The subagent tool cannot invoke itself. Two guards enforce this:
- A self-reference check rejects a subagent entry inside the subagent’s own
toolsarray (and rejects the subagent tool name as the workermodel). - Each inner subagent call carries an
x-openrouter-subagent-depthheader; the subagent tool is stripped from any sub-call, so a worker can never re-enter the subagent.
Task executions are also capped per request to bound cost and latency.
Related
- Advisor server tool — consult a stronger model for guidance
- Fusion server tool — multi-model deliberation
- Web Search server tool