Worker-internal subagents — delegate_subtask (T313)
Implementer-class loop workers (loop--build) automatically get a delegatesubtask tool that lets the worker spawn a scoped subagent — a focused nested LoopAgentAdapter with its own system prompt, a...
Implementer-class loop workers (loop-*-build) automatically get a delegate_subtask tool that
lets the worker spawn a scoped subagent — a focused nested LoopAgentAdapter with its own system
prompt, a caller-restricted tool set, and an isolated context window.
Use cases:
- A worker that must write code AND investigate a codebase section can delegate the investigation to a read-only subagent, keeping its own context clean for writing.
- A worker can delegate a test run to a subagent that only has
run_bash, returning a bounded result without tool-call noise in the parent.
Recursion cap — nesting is bounded by CYBERINE_SUBAGENT_NESTING_CAP (default 2). A call
that would exceed the cap is refused and returns an error string to the parent. Set to 0 to
disable delegation entirely.
Usage/cost — the subagent's LLM token usage rolls up into the parent run's Usage object, so
cost accounting stays accurate end-to-end.
How the model calls it:
{
"name": "delegate_subtask",
"arguments": {
"task": "Scan src/auth/ for all exported function signatures. Return a list.",
"system_prompt": "You are a codebase investigator. Read files, list directories, search with grep. Return a structured summary. Be concise.",
"tools": ["read_file", "list_dir", "grep_files"],
"max_tool_rounds": 8,
"max_tokens": 4096
}
}Parameters:
| Field | Required | Default | Description |
|---|---|---|---|
task | yes | — | The sub-task text. Self-contained — the subagent has no parent context. |
system_prompt | no | (none) | Persona / constraints for the subagent. Prepended to the task. |
tools | no | [] (text-only) | Names from the parent's tool set the subagent may use. Unknown names error immediately. |
max_tool_rounds | no | 6 | Tool-calling budget for the subagent (max 20). |
max_tokens | no | 4096 | Max completion tokens per API call inside the subagent's loop. |
Env vars:
| Var | Default | Purpose |
|---|---|---|
CYBERINE_SUBAGENT_NESTING_CAP | 2 | Maximum nesting depth. 0 disables delegation. |
Extend recipe — to enable subagents on a custom adapter, pass enableSubagents: true to
LoopAgentAdapterOptions. The delegate tool is auto-injected and closes over the adapter's
connection details (baseURL / apiKey / model) so the subagent reaches the same endpoint:
new LoopAgentAdapter({
id: 'my-worker',
provider: 'deepseek:deepseek-v4-pro',
model: 'deepseek-v4-pro',
baseURL: 'https://api.deepseek.com',
apiKey: process.env.DEEPSEEK_API_KEY!,
tools: myTools,
enableSubagents: true, // inject delegate_subtask
})Idle-stream watchdog — abort a stalled stream, fleet worker + chat (T562, T570)
Claude Code v2.1.196 made a streaming idle watchdog default-on: it aborts and retries a response stream that produces no events for 5 minutes. LoopAgentAdapter (fleet workers) AND the interactive...
Tool-call pipeline — batch multi-tool sequences in one model turn (T319)
Implementer-class loop workers (loop--build) automatically get a runpipeline tool that lets a worker express a predictable multi-step tool sequence as a single tool call, collapsing N sequential...