Skip to main content

Sub-agents

Sub-agents let a model hand a focused piece of work to a second agent that runs in parallel, then use the result to continue. The model decides when to delegate by calling the delegate_task builtin tool.

A sub-agent is a full chat completion of its own. It runs with the same tools, skills and filters as the chat that spawned it, on the current model or one of the sub-agent models set on it, works through the task on its own, and hands back its final answer. The work happens in a separate chat that is kept out of your chat list, so the parent conversation stays readable.

Sub-agents are disabled by default. An administrator enables them with the ENABLE_SUBAGENTS environment variable or the Settings > Sub-agents (admin section) toggle.

What a Sub-agent Is Told​

A sub-agent builds its instructions the way a new chat message does, starting from the parent chat's original setup: the chat's own system prompt (from Model controls > Controls or your Settings), the model's system prompt, the chat's variables and the full text of any skills mentioned in the message. The folder's system prompt, tool server and terminal instructions are applied for the sub-agent's own run, along with the sub-agent system prompt.

A background sub-agent's result continues the parent chat with instructions built the same way.

Why Delegate​

Delegation buys focus and parallelism in three ways.

  • A clean context per task. The sub-agent gets only the task and the context handed to it, so a long chat does not dilute the work.
  • Real parallelism. When a model requests several delegations in one reply, they run at the same time.
  • A short answer back. Only the sub-agent's final result returns to the parent chat. The intermediate tool calls, searches and dead ends stay in the sub-agent's own chat.

Typical uses are researching several questions at once, working through a task that needs many tool calls, and doing a self-contained job whose intermediate steps do not belong in the main thread.

Foreground and Background​

Outside channels and automation runs, sub-agents run in the background. The model carries on while the sub-agent works. When the sub-agent finishes, its result is posted back into the parent chat and the chat continues on its own, without you sending anything. The result appears as a collapsible row with the sub-agent's status, the task's title and how long it ran. Expand it to read the result, and click Open thread to open the sub-agent's chat. If the parent chat is busy at that moment, the result waits and is delivered when the chat is free.

In a channel and in an automation run, sub-agents run in the foreground. The reply waits for the sub-agent and receives its answer as the tool result, the same as any other tool call.

Following Sub-agents​

The Status button in the chat's top bar lists the chat's sub-agents and scheduled timers under Threads. Click a sub-agent to open its chat in a tab, or Stop it. Cancel removes a timer before it fires.

Messages Between Chats​

With sub-agents on, the model in a saved chat also gets the send_message tool. It sends a message to another of your chats, such as a sub-agent or the parent chat. A chat that is working reads the message between its tool calls, and an idle one wakes up to read it. The message shows in the receiving chat as a collapsible row with the sending chat's title. Expand it to read the message, and click Open thread to open the sending chat. A chat that is waiting for you to approve a tool does not take messages.

Handing Over Files​

A sub-agent starts with no attachments. Nothing the parent chat has uploaded travels with the task on its own, so delegating does not quietly drag every file in a long conversation into a second model call.

To pass a file, the model names it in the file_ids argument of delegate_task. Those files are attached to the sub-agent's opening message as if you had attached them yourself. An image is handed to the model as an image, so a vision model can actually look at it, and a document is available to the sub-agent exactly as it is in a normal chat, injected when Preload files is on or read with the Files builtin tools when it is off.

Only files already attached in the parent chat can be passed, and every ID is checked before anything runs. If one of them is unknown or no longer available, the call comes back as Error: file_ids not attached or unavailable: <ids> and no sub-agent is started.

A file ID written into context is only text. The sub-agent receives the ID and no file, so anything it has to open belongs in file_ids.

Enable Sub-agents​

Sub-agents need four things to line up.

  1. Globally enabled: ENABLE_SUBAGENTS, or Settings > Sub-agents (admin section).
  2. Enabled for the model: the Sub-agents category under Builtin Tools in Settings > Models > Edit (admin section) (or Workspace > Models for your own model), on by default once the feature is on.
  3. The user's permission: the Sub-agents switch under Features in the default and group permissions, or USER_PERMISSIONS_FEATURES_SUBAGENTS. Users without it get none of delegate_task, send_message and timer.
  4. Builtin tools in the chat: delegate_task is a builtin tool, so Function Calling must not be set to Legacy and the model's Builtin Tools capability must be on. Chats, channels and automation runs all qualify. Temporary chats get no sub-agent tools.

Admins always pass the permission check.

Admin Limits​

Configure these in Settings > Sub-agents (admin section), or with the matching environment variables.

Sub-agent settings

SettingVariableDefaultPurpose
Max concurrentSUBAGENTS_MAX_CONCURRENTEmpty (unlimited)Foreground sub-agents (channels and automation runs) at once. Extra ones wait for a slot.
Max backgroundSUBAGENTS_MAX_ASYNCEmpty (unlimited)Background sub-agents (all other chats) at once. Extra ones are refused immediately.
Max iterationsSUBAGENTS_MAX_ITERATIONSEmpty (unlimited)Tool-call rounds one sub-agent may run. At the limit it writes a final answer without tools, and that answer goes back to the parent.
Max outputSUBAGENTS_MAX_OUTPUTEmpty (unlimited)Characters returned to the parent. Longer results are truncated.
System promptSUBAGENTS_SYSTEM_PROMPTBuilt-inReplaces the built-in sub-agent prompt. The result is added to the model's own system prompt.

Three limits are worth understanding before changing them.

  • They count per worker process. With multiple workers or replicas, the real ceiling is the limit multiplied by the number of processes.
  • Changing Max concurrent needs a restart. Its limit is applied to a semaphore created at the first limited foreground delegation and never resized. Max background applies immediately.
  • A limit is a positive whole number. Empty or 0 means no limit. Use ENABLE_SUBAGENTS to turn the feature off.

What a Sub-agent Cannot Do​

Sub-agents are narrower than the parent chat in these ways.

  • No recursion. A sub-agent cannot delegate again or set timers, so delegation cannot fan out without bound.
  • No ask_user. A sub-agent cannot pause to ask you a question, and a tool call that needs your approval pauses it until you approve. It can still send a message to the parent chat.
  • No memory writes. It can read memories but cannot add, change or delete them, keeping delegated work from quietly rewriting your personalization.
  • No code interpreter in the background, unless the engine is Jupyter, since the browser-based Pyodide engine needs a live session.
  • Sub-agent targets. The Sub-agents list offers the instance's own models.
  • No access to your terminal tab. The tools that read or type into the terminal tab you have open are not available to a sub-agent.

Each sub-agent runs in its own chat. These chats are hidden from chat lists and search, and are deleted together with the parent chat. Admins can read them by id only while ENABLE_ADMIN_CHAT_ACCESS is on, the same as other chats.

Cost​

Every delegation is another full chat completion, with the same tools, and may loop up to the iteration limit. One reply can start several at once, and each background result restarts the parent chat to process it, which is another turn.

No limits are set by default, so only the model decides how many sub-agents run and how long they loop. On a metered API, set the Admin Limits.

What delegation costs shows up in Analytics next to everything else.

Managing Sub-agents from Chat​

Available tools​

ToolPurpose
delegate_taskDelegate a task to a parallel sub-agent.
send_messageSend a message to another of the user's chats, such as a sub-agent or the chat that started it.

delegate_task takes the task to perform, optional context to carry across (decisions, file paths, findings), optional file_ids naming attachments the sub-agent has to open (see Handing Over Files), model_id to pick one of the model's sub-agent models, and a short title for the task, which names the sub-agent's chat. send_message takes the chat_id of the receiving chat and the message.

The Sub-agents list in the model editor gives the parent model additional targets it can choose. When a delegate_task call omits model_id, the sub-agent runs on the current model even if the list contains other models.

If the expected target is missing, check that the target is configured on the parent model and available to the user running the chat. Open WebUI offers only configured targets the user can access. If no targets qualify, the tool omits the model_id parameter.

The Sub-agents category also controls timers

The timer tool comes from the same category and the same ENABLE_SUBAGENTS toggle. Turning sub-agents off stops new timers, and timers already set still fire.

This content is for informational purposes only and does not constitute a warranty, guarantee, or contractual commitment. Open WebUI is provided "as is." See your license for applicable terms.