# SubAgent

> **Class** in `deepagents`

📖 [View in docs](https://reference.langchain.com/python/deepagents/middleware/subagents/SubAgent)

Specification for an agent.

When using `create_deep_agent`, subagents automatically receive
a default middleware stack before any custom `middleware` specified in
this spec.

## Signature

```python
SubAgent()
```

## Description

**Required fields:**

name: Unique identifier for the subagent.

    The main agent uses this name when calling the `task()` tool.
description: What this subagent does.

    Be specific and action-oriented. The main agent uses this
    to decide when to delegate.
system_prompt: Instructions for the subagent.

    Include tool usage guidance and output format requirements.

**Optional fields:**

tools: Tools the subagent can use.

    If not specified, inherits tools from the main agent
    via `default_tools`.
model: Override the main agent's model.

    Use the format `'provider:model-name'` (e.g., `'openai:gpt-5.5'`).
middleware: Additional middleware for custom behavior, logging,
    or rate limiting. To restrict filesystem tools, include a
    `FilesystemMiddleware(tools=...)` instance here — it
    will be used as the subagent's filesystem middleware instead of
    the default one.
interrupt_on: Configure human-in-the-loop for specific tools.

    Requires a checkpointer.
skills: Skill source paths for `SkillsMiddleware`.

    List of paths to skill directories
    (e.g., `["/skills/user/", "/skills/project/"]`).
permissions: Filesystem permission rules for this subagent.

    If omitted, inherits the parent agent's permissions. If provided,
    replaces the parent agent's rules entirely for this subagent.

    Rules are evaluated in declaration order; the first match wins.

## Extends

- `TypedDict`

## Constructors

```python
__init__(
    name: str,
    description: str,
    system_prompt: str,
    tools: NotRequired[Sequence[BaseTool | Callable | dict[str, Any]]],
    model: NotRequired[str | BaseChatModel],
    middleware: NotRequired[list[AgentMiddleware]],
    interrupt_on: NotRequired[dict[str, bool | InterruptOnConfig]],
    skills: NotRequired[list[str]],
    permissions: NotRequired[list[FilesystemPermission]],
    response_format: NotRequired[ResponseFormat[Any] | type | dict[str, Any]],
)
```

| Name | Type |
|------|------|
| `name` | `str` |
| `description` | `str` |
| `system_prompt` | `str` |
| `tools` | `NotRequired[Sequence[BaseTool \| Callable \| dict[str, Any]]]` |
| `model` | `NotRequired[str \| BaseChatModel]` |
| `middleware` | `NotRequired[list[AgentMiddleware]]` |
| `interrupt_on` | `NotRequired[dict[str, bool \| InterruptOnConfig]]` |
| `skills` | `NotRequired[list[str]]` |
| `permissions` | `NotRequired[list[FilesystemPermission]]` |
| `response_format` | `NotRequired[ResponseFormat[Any] \| type \| dict[str, Any]]` |


## Properties

- `name`
- `description`
- `system_prompt`
- `tools`
- `model`
- `middleware`
- `interrupt_on`
- `skills`
- `permissions`
- `response_format`

---

[View source on GitHub](https://github.com/langchain-ai/deepagents/blob/3afad63e2290559c36a1c386ab2ac9a2d1f8b64a/libs/deepagents/deepagents/middleware/subagents.py#L36)