ViteHub is still experimental. Expect bugs and breaking changes.

Subagents

Delegate bounded work to named Agent Definitions through model-facing tools.

subagents() exposes one tool per configured child Agent Definition. Use it when the main Agent should delegate bounded work without giving the model a generic agent runner.

Installation

Import the Capability factory from @vite-hub/agent/capabilities and add it to defineAgent({ capabilities }). Name each subagent with a lowercase stable identifier and give it a concrete description.

What it adds

The Capability adds model-facing tools such as run_researcher or an explicit toolName. Each tool starts the configured child Agent with a message, optional structured context, optional call options, and an inherited invoker.

Configuration

server/agents/support.ts
import { defineAgent } from '@vite-hub/agent'
import { subagents } from '@vite-hub/agent/capabilities'
import researcher from './researcher'

export default defineAgent({
  driver: { model },
  capabilities: [
    subagents({
      agents: {
        researcher: {
          agent: researcher,
          description: 'Research one narrow question and return sourced notes.',
        },
      },
    }),
  ],
})

Runtime behavior

subagents() validates the configured names and tool names before the Agent runs. At invocation time, each subagent tool calls runAgent() with the parent runtime context and a child run id derived from the parent run id when available.

Requirements

Each subagent entry requires an agent and a non-empty description. Subagent keys must be lowercase stable identifiers, and generated tool names use underscores instead of dashes.

Driver support

Agent DriverSupport
Model-backedReceives one model-facing tool per subagent.
Harness-backedDoes not receive model-facing subagent tools by default.
Custom-run-backedCan inspect the configured tools and invoke child Agents directly if the custom runner chooses to.

Options

OptionTypeDefaultDescription
agentsRecord<string, SubagentDefinition>requiredNamed child Agent Definitions exposed as tools.
idstring"subagents"Capability id and instruction context key.
instructionsstring | falsegeneratedOverride or disable the generated delegation instructions.
agents.*.agentAgentInputrequiredChild Agent Definition or Agent input accepted by runAgent().
agents.*.descriptionstringrequiredTool description shown to the model.
agents.*.instructionsstringnoneExtra generated instructions for that child Agent.
agents.*.toolNamestringrun_<name>Explicit model-facing tool name.

Inspect and verify

Open Agent DevTools and confirm each subagent appears as a tool with the expected name and description. Run one delegated task and verify the child invocation id and inherited invoker metadata.

Reference

Copyright © 2026