Skip to content

Commit 3bd1997

Browse files
open-swe[bot]open-swesydney-runklenpentrel
authored
feat: add subagent documentation to deploy page (#3615)
## Description Adds comprehensive subagent documentation to the "Deploy with the CLI" page based on the implementation in langchain-ai/deepagents#2786. Subagents are auto-discovered from a `subagents/` directory and let the main agent delegate specialized tasks to isolated child agents with their own system prompts, skills, and MCP tools. By default, subagents inherit model and tools from the main agent but not skills. ## Test Plan - [ ] Test in preview deployment _Opened collaboratively by Sydney Runkle and open-swe._ --------- Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com> Co-authored-by: Sydney Runkle <54324534+sydney-runkle@users.noreply.github.com> Co-authored-by: Naomi Pentrel <5212232+npentrel@users.noreply.github.com>
1 parent cfcacc0 commit 3bd1997

File tree

2 files changed

+141
-7
lines changed

2 files changed

+141
-7
lines changed

src/oss/deepagents/deploy.mdx

Lines changed: 139 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ Deep Agents Deploy takes your agent configuration and deploys it as a [LangSmith
4040
| **`skills`** | [Agent Skills](https://agentskills.io/) for specialized knowledge and actions. Skills are synced into the sandbox so the agent can execute them at runtime. See [skills docs](/oss/deepagents/skills). |
4141
| **``user/``** | Per-user writable memory. If a `AGENTS.md` template is present in the `user` folder, the agents seeds the template per user (if the folder is empty the agents creates an empty `AGENTS.md`). Writable at runtime. Preloaded into the agent's context via the memory middleware. |
4242
| **`mcp.json`** | MCP tools (HTTP/SSE). See [MCP docs](/oss/langchain/mcp). |
43+
| **`subagents/`** | Specialized [subagents](/oss/deepagents/subagents) the main agent can delegate to. Each subdirectory contains its own `deepagents.toml`, `AGENTS.md`, and optionally a `skills` folder. See [subagents](#subagents). |
4344
| **`sandbox`** | Optional execution environment. Thread-scoped sandboxes are provisioned per thread and will be re-created if the server restarts. Use `scope = "assistant"` if you need sandbox state that persists across threads. See [sandbox providers](#sandbox-providers). |
4445

4546
## Install
@@ -107,6 +108,10 @@ my-agent/
107108
│ │ └── SKILL.md
108109
│ └── data-analysis/
109110
│ └── SKILL.md
111+
├── subagents/
112+
│ └── researcher/
113+
│ ├── deepagents.toml
114+
│ └── AGENTS.md
110115
└── user/
111116
└── AGENTS.md
112117
```
@@ -116,6 +121,7 @@ my-agent/
116121
| `AGENTS.md` | [Memory](/oss/deepagents/memory) for the agent. Provides persistent context (project conventions, instructions, preferences) that is always loaded at startup. Read-only at runtime. | Yes |
117122
| `skills/` | Directory of [skill](/oss/deepagents/skills) definitions. Each subdirectory should contain a `SKILL.md` file. Read-only at runtime. | No |
118123
| `user/` | Per-user writable memory. If a `AGENTS.md` template is present in the `user` folder, the agents seeds the template per user (if the folder is empty the agents creates an empty `AGENTS.md`). Writable at runtime. Preloaded into the agent's context via the memory middleware. | No |
124+
| `subagents/` | [Subagents](#subagents) the main agent can delegate to. Each subdirectory must contain a `deepagents.toml`, `AGENTS.md`, and optionally a `skills` folder. Auto-discovered at bundle time. | No |
119125
| `mcp.json` | [MCP](https://modelcontextprotocol.io/) server configuration. Only `http` and `sse` transports are supported in deployed contexts. | No |
120126
| `.env` | Environment variables (API keys, secrets). Placed alongside `deepagents.toml` at the project root. | No |
121127

@@ -153,12 +159,13 @@ model = "google_genai:gemini-3.1-pro-preview"
153159
The `name` field is the only required value in the entire configuration file. Everything else has defaults.
154160
</Note>
155161

156-
Skills, user memories, MCP servers, and model dependencies are auto-detected from the project layout — you don't declare them in `deepagents.toml`:
162+
Skills, user memories, subagents, MCP servers, and model dependencies are auto-detected from the project layout:
157163

158164
- **Skills**: the bundler recursively scans `skills/`, skipping hidden dotfiles, and bundles the rest.
159165
- **User memory**: if `user/` exists, a single `AGENTS.md` is bundled as per-user memory (from `user/AGENTS.md` if present, otherwise empty). At runtime, each user gets their own copy (seeded on first access, never overwritten). The agent can read from and write to this file.
166+
- **Subagents**: if `subagents/` exists, the bundler scans for valid subdirectories (each must contain `deepagents.toml` and `AGENTS.md`). The main agent receives a `task` tool to delegate work to each subagent by name. See [subagents](#subagents).
160167
- **MCP servers**: if `mcp.json` exists, it is included in the deployment and [`langchain-mcp-adapters`](https://pypi.org/project/langchain-mcp-adapters/) is added as a dependency. Only HTTP/SSE transports are supported (stdio is rejected at bundle time).
161-
- **Model dependencies**: the `provider:` prefix in the `model` field determines the required `langchain-*` package (e.g., `google_genai` -> `langchain-google-genai`).
168+
- **Model dependencies**: the `provider:` prefix in the `model` field determines the required `langchain-*` package (e.g., `google_genai` -> `langchain-google-genai`). This includes models specified in subagent configs.
162169
- **Sandbox dependencies**: the `[sandbox].provider` value maps to its partner package (e.g., `daytona` -> `langchain-daytona`).
163170

164171
### `[sandbox]`
@@ -256,6 +263,24 @@ template = "coding-agent"
256263
image = "python:3.12"
257264
```
258265

266+
A GTM strategy agent that delegates research to a subagent:
267+
268+
```txt
269+
my-gtm-agent/
270+
├── deepagents.toml
271+
├── AGENTS.md
272+
├── skills/
273+
│ └── competitor-analysis/
274+
│ └── SKILL.md
275+
└── subagents/
276+
└── market-researcher/
277+
├── deepagents.toml
278+
├── AGENTS.md
279+
└── skills/
280+
└── analyze-market/
281+
└── SKILL.md
282+
```
283+
259284
## User Memory
260285

261286
User memory gives each user their own writable `AGENTS.md` that persists across conversations. To enable it, create a `user/` directory at your project root:
@@ -283,17 +308,124 @@ At runtime, user memory is scoped per user via custom auth (`runtime.server_info
283308
| `/memories/AGENTS.md` | No | Shared (assistant-scoped) |
284309
| `/memories/skills/**` | No | Shared (assistant-scoped) |
285310
| `/memories/user/**` | Yes | Per-user (`user_id`-scoped) |
311+
| `/memories/subagents/<name>/**` | By subagent only | Per-subagent (isolated) |
286312

287313
### User identity
288314

289315
The `user_id` is resolved from custom auth via `runtime.user.identity`. The platform injects the authenticated user's identity automatically — no need to pass it through `configurable`. If no authenticated user is present, user memory features are gracefully skipped for that invocation.
290316

291-
## Gotchas
317+
## Subagents
318+
319+
Subagents let the main agent delegate specialized tasks to isolated child agents. Each subagent has its own system prompt, optional skills, and optional MCP tools. The main agent receives a `task` tool that dispatches work to subagents by name.
320+
321+
For background on why subagents are useful and how they work at the SDK level, see [Subagents](/oss/deepagents/subagents).
322+
323+
### Directory structure
324+
325+
Create a `subagents/` directory at your project root. Each subdirectory is a subagent:
326+
327+
```txt
328+
my-agent/
329+
├── deepagents.toml
330+
├── AGENTS.md
331+
└── subagents/
332+
├── researcher/
333+
│ ├── deepagents.toml # name, description, optional model override
334+
│ ├── AGENTS.md # subagent system prompt
335+
│ ├── skills/ # optional — subagent-specific skills
336+
│ │ └── analyze-market/
337+
│ │ └── SKILL.md
338+
│ └── mcp.json # optional — HTTP/SSE MCP tools
339+
└── writer/
340+
├── deepagents.toml
341+
└── AGENTS.md
342+
```
343+
344+
Each subagent subdirectory **must** contain:
345+
346+
| File | Purpose |
347+
| --- | --- |
348+
| `deepagents.toml` | Subagent config with `[agent].name` and `[agent].description` |
349+
| `AGENTS.md` | System prompt for the subagent |
350+
351+
Each subagent subdirectory **may** contain:
352+
353+
| File | Purpose |
354+
| --- | --- |
355+
| `skills/` | Subagent-specific skills (with `SKILL.md` files) |
356+
| `mcp.json` | MCP server configuration (HTTP/SSE only; stdio is rejected) |
357+
358+
### Subagent configuration
359+
360+
<ResponseField name="name" type="string" required>
361+
Unique identifier for the subagent. Must be unique across all subagents.
362+
</ResponseField>
363+
364+
<ResponseField name="description" type="string" required>
365+
What this subagent does. The main agent uses this to decide when to delegate. Must be non-empty.
366+
</ResponseField>
367+
368+
<ResponseField name="model" type="string">
369+
Model override in `provider:model` format. Omit to inherit the main agent's model.
370+
</ResponseField>
371+
372+
```toml subagents/researcher/deepagents.toml
373+
[agent]
374+
name = "researcher"
375+
description = "Researches market trends, competitors, and target audiences"
376+
model = "anthropic:claude-haiku-4-5-20251001"
377+
```
378+
379+
### Inheritance
380+
381+
Subagents inherit some properties from the main agent by default:
382+
383+
| Property | Inherited | Notes |
384+
| --- | --- | --- |
385+
| Model | Yes | Override with `model` in the subagent's `deepagents.toml` |
386+
| Tools | Yes | Override by adding `mcp.json` to the subagent directory |
387+
| Skills | No | Declare explicitly in the subagent's own `skills/` directory |
388+
389+
### Memory isolation
390+
391+
Each subagent gets a dedicated, isolated memory namespace at `/memories/subagents/<name>/`. The subagent's `AGENTS.md` and skills are seeded into this namespace at deploy time.
392+
393+
| Path | Main agent | Subagent |
394+
| --- | --- | --- |
395+
| `/memories/AGENTS.md` | Read | No access |
396+
| `/memories/skills/**` | Read | No access |
397+
| `/memories/user/**` | Read + Write | No access |
398+
| `/memories/subagents/<name>/**` | Read | Read + Write |
399+
400+
### Example
401+
402+
A go-to-market agent that delegates research to a specialized subagent:
403+
404+
```toml deepagents.toml
405+
[agent]
406+
name = "gtm-strategist"
407+
model = "anthropic:claude-sonnet-4-6"
408+
```
409+
410+
```toml subagents/researcher/deepagents.toml
411+
[agent]
412+
name = "researcher"
413+
description = "Researches market trends, competitors, and target audiences to inform GTM strategy"
414+
model = "anthropic:claude-haiku-4-5-20251001"
415+
```
416+
417+
```markdown subagents/researcher/AGENTS.md
418+
# Market Researcher
419+
420+
You are a market research specialist. Your job is to gather and synthesize
421+
market data to support go-to-market decisions.
422+
423+
## Focus Areas
424+
- Market sizing: TAM, SAM, SOM estimates
425+
- Competitor analysis: product positioning, pricing, market share
426+
- Audience segmentation: demographics, psychographics, buying behavior
427+
```
292428

293-
- **AGENTS.md and skills are read-only at runtime.** Edit source files and redeploy to update them. The per-user `AGENTS.md` at `/memories/user/AGENTS.md` is the exception — it is writable by the agent.
294-
- **Full rebuild on deploy:** `deepagents deploy` creates a new revision on every invocation. Use `deepagents dev` for local iteration.
295-
- **Sandbox lifecycle:** Thread-scoped sandboxes are provisioned per thread and will be re-created if the server restarts. Use `scope = "assistant"` if you need sandbox state that persists across threads.
296-
- **MCP: HTTP/SSE only.** Stdio transports are rejected at bundle time.
297429
## Limitations
298430

299431
- **MCP: HTTP/SSE only.** Stdio transports are rejected at bundle time.

src/oss/deepagents/subagents.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ For most use cases, define subagents as dictionaries matching the @[`SubAgent`]
8484

8585
<Tip>
8686
**CLI users:** You can also define subagents as `AGENTS.md` files on disk instead of in code. The `name`, `description`, and `model` fields map to YAML frontmatter, and the markdown body becomes the `system_prompt`. See [Custom subagents](/oss/deepagents/cli/overview#subagents) for the file format.
87+
88+
**Deploy users:** Define subagents as directories under `subagents/` with their own `deepagents.toml` and `AGENTS.md`. The bundler auto-discovers them. See [Deploy subagents](/oss/deepagents/deploy#subagents) for the full configuration reference.
8789
</Tip>
8890

8991
### CompiledSubAgent

0 commit comments

Comments
 (0)