# CompiledSubAgent

> **Class** in `deepagents`

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

A pre-compiled agent spec.

!!! note

    The runnable's state schema must include a 'messages' key.

    This is required for the subagent to communicate results back to the main agent.

When the subagent completes, the final message in the 'messages' list will be
extracted and returned as a `ToolMessage` to the parent agent.

## Signature

```python
CompiledSubAgent()
```

## Extends

- `TypedDict`

## Constructors

```python
__init__(
    name: str,
    description: str,
    runnable: Runnable,
)
```

| Name | Type |
|------|------|
| `name` | `str` |
| `description` | `str` |
| `runnable` | `Runnable` |


## Properties

- `name`
- `description`
- `runnable`

---

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