---
description: Let agents delegate focused work to named specialists.
---

# Subagents

Last updated May 29, 2026 [ View as Markdown](https://flueframework.com/docs/guide/subagents/index.md) 

Subagents let an agent delegate a piece of work to a named specialist while it continues to own the interaction. Use them when an agent should ask another configured role to research, classify, or review something and then work with the returned answer.

A subagent is an [agent profile](https://flueframework.com/docs/guide/building-agents/#agent-profiles) declared on another agent. Delegated work runs in a separate child session, rather than continuing the parent agent’s conversation history. The subagent is not a separately addressable agent endpoint.

## Define a subagent

Create a named profile with `defineAgentProfile(...)`, then provide it through an agent’s `subagents` configuration:

```
import { createAgent, defineAgentProfile } from '@flue/runtime';

const issueClassifier = defineAgentProfile({
  name: 'issue_classifier',
  description: 'Classifies support issues for routing.',
  instructions: 'Return the likely product area and urgency for the reported issue.',
});

export default createAgent(() => ({
  model: 'anthropic/claude-sonnet-4-6',
  instructions: 'Help resolve support requests. Delegate classification when it helps your answer.',
  subagents: [issueClassifier],
}));
```

In this example, `support-assistant` can delegate work to `issue_classifier`. The profile configures the specialist used for delegated tasks; it does not define another agent at `/agents/issue_classifier/:id`.

## Delegate work

An agent with configured subagents can decide to delegate while answering a prompt. Flue gives the agent a built-in `task` capability that starts a child session for the selected subagent and returns that child’s answer to the parent agent.

The child session receives the delegated request and its own configured context, not the parent’s existing conversation transcript. When a subagent works in a configured sandbox, it uses that same sandbox boundary as its parent. See [Sandboxes](https://flueframework.com/docs/guide/sandboxes/) for controlling workspace and command access.

## Use subagents in workflows

A workflow can choose delegation directly when application logic requires work from a particular subagent. Call `session.task(...)` with the name of a declared subagent, and provide `result` when the workflow needs validated data:

```
import { createAgent, defineAgentProfile, type FlueContext } from '@flue/runtime';
import * as v from 'valibot';

const reviewer = defineAgentProfile({
  name: 'reviewer',
  instructions: 'Review the proposed change and identify concrete correctness risks.',
});

const coordinator = createAgent(() => ({
  model: 'anthropic/claude-sonnet-4-6',
  subagents: [reviewer],
}));

const Review = v.object({
  summary: v.string(),
  risks: v.array(v.string()),
});

export async function run({ init, payload }: FlueContext<{ change: string }>) {
  const harness = await init(coordinator);
  const session = await harness.session();
  const response = await session.task(payload.change, {
    agent: 'reviewer',
    result: Review,
  });

  return response.data;
}
```

Here, the workflow chooses `reviewer` rather than leaving delegation to the parent agent. See [Workflows](https://flueframework.com/docs/guide/workflows/) for workflow orchestration and the [Agent API](https://flueframework.com/docs/api/agent-api/) for task options and result types.

## Next steps

* [Agents](https://flueframework.com/docs/guide/building-agents/) — create agents and reusable agent profiles.
* [Workflows](https://flueframework.com/docs/guide/workflows/) — orchestrate finite agent work in application code.
* [Tools](https://flueframework.com/docs/guide/tools/) and [Skills](https://flueframework.com/docs/guide/skills/) — give an agent profile capabilities and reusable instructions.
* [Sandboxes](https://flueframework.com/docs/guide/sandboxes/) — control the workspace available during delegated work.
* [Agent API](https://flueframework.com/docs/api/agent-api/) — look up `session.task(...)` options and results.
* [Observability](https://flueframework.com/docs/guide/observability/) — inspect delegated activity alongside other agent work.

## Docs Navigation

Current page: [Subagents](https://flueframework.com/docs/guide/subagents/)

### Sections

* [Guide](https://flueframework.com/docs/getting-started/quickstart/)
* [Reference](https://flueframework.com/docs/api/agent-api/)
* [CLI](https://flueframework.com/docs/cli/overview/)
* [SDK](https://flueframework.com/docs/sdk/overview/)
* [Ecosystem](https://flueframework.com/docs/ecosystem/overview/)

### Introduction

* [ Getting Started ](https://flueframework.com/docs/getting-started/quickstart/)
* [ What is an agent? ](https://flueframework.com/docs/concepts/agents/)
* [ Why Flue? ](https://flueframework.com/docs/introduction/why-flue/)
* [ Changelog ](https://github.com/withastro/flue/blob/main/CHANGELOG.md)

### Guides

* [ Project Layout ](https://flueframework.com/docs/guide/project-layout/)
* [ Models & Providers ](https://flueframework.com/docs/guide/models/)
* [ Agents ](https://flueframework.com/docs/guide/building-agents/)
* [ Workflows ](https://flueframework.com/docs/guide/workflows/)
* [ Skills ](https://flueframework.com/docs/guide/skills/)
* [ Tools ](https://flueframework.com/docs/guide/tools/)
* [ Subagents ](https://flueframework.com/docs/guide/subagents/)
* [ Sandboxes ](https://flueframework.com/docs/guide/sandboxes/)
* [ Routing ](https://flueframework.com/docs/guide/routing/)
* [ Develop & Build ](https://flueframework.com/docs/guide/develop-and-build/)
* [ Chat ](https://flueframework.com/docs/guide/chat/)
* [ Observability ](https://flueframework.com/docs/guide/observability/)