Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions docs/multi-agent-applications.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# Multi-agent Applications

There are roughly four levels of complexity when building applications with Pydantic AI:
There are roughly five levels of complexity when building applications with Pydantic AI:

1. Single agent workflows — what most of the `pydantic_ai` documentation covers
2. [Agent delegation](#agent-delegation) — agents using another agent via tools
3. [Programmatic agent hand-off](#programmatic-agent-hand-off) — one agent runs, then application code calls another agent
4. [Graph based control flow](graph.md) — for the most complex cases, a graph-based state machine can be used to control the execution of multiple agents
5. [Deep Agents](#deep-agents) — production-grade agents with planning, file operations, task delegation, and sandboxed code execution

Of course, you can combine multiple strategies in a single application.

Expand Down Expand Up @@ -322,8 +323,23 @@ graph TB

See the [graph](graph.md) documentation on when and how to use graphs.

## Deep Agents

Deep agents are production-grade autonomous agents that go beyond simple tool use. They combine multiple architectural patterns to handle complex, multi-step tasks reliably:

- **Planning and progress tracking** — agents break down complex tasks into steps and track their progress, giving users visibility into what the agent is working on
- **File system operations** — reading, writing, and editing files with proper abstraction layers that work across in-memory storage, real file systems, and sandboxed containers
- **Task delegation** — spawning specialized sub-agents for specific tasks, with isolated context to prevent recursive delegation issues
- **Sandboxed code execution** — running AI-generated code in isolated environments (typically Docker containers) to prevent accidents
- **Context management** — automatic conversation summarization to handle long sessions that would otherwise exceed token limits
- **Human-in-the-loop** — approval workflows for dangerous operations like code execution or file deletion

These patterns emerged from teams building production agents (like [Claude Code](https://docs.anthropic.com/en/docs/agents-and-tools/claude-code/overview) and [Manus](https://manus.im/)) and discovering what actually works at scale.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's drop this paragraph


[Pydantic-Deep](https://github.com/vstorm-co/pydantic-deepagents) implements these deep agent patterns for Pydantic AI. See the [toolsets documentation](toolsets.md#pydantic-deep) for usage examples and the [full demo application](https://github.com/vstorm-co/pydantic-deepagents/tree/main/examples/full_app) for a complete example with a chat interface, file uploads, skills, and streaming responses.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to make it clear that each of the items in the list above can already be implemented using some Pydantic AI feature / 3rd party package, (we should have links to each doc, e.g. the toolset sections you're gonna add), and that if one doesn't want to piece this together oneself, Pydantic-Deep is a community package that offers an opinionated take on a deep agent by leveraging these same features.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm happy to take a crack at this at the end to make it sound a little bit more from-Pydantic than from-VStorm.


## Examples

The following examples demonstrate how to use dependencies in Pydantic AI:
The following examples demonstrate how to use multi-agent patterns in Pydantic AI:

- [Flight booking](examples/flight-booking.md)
15 changes: 15 additions & 0 deletions docs/toolsets.md
Original file line number Diff line number Diff line change
Expand Up @@ -708,3 +708,18 @@ toolset = ACIToolset(

agent = Agent('openai:gpt-5', toolsets=[toolset])
```

### Pydantic-Deep {#pydantic-deep}

[Pydantic-Deep](https://github.com/vstorm-co/pydantic-deepagents), built by [Vstorm](https://vstorm.co/), brings deep agent patterns to Pydantic AI. Deep agents are production-grade agents with planning, file system operations, task delegation, and sandboxed code execution — patterns derived from production systems like Claude Code and Manus.

Available toolsets:

- `TodoToolset`: Task planning and progress tracking for agent self-organization
- `FilesystemToolset`: File operations (ls, read, write, edit, glob, grep, execute)
- `SubAgentToolset`: Spawn and delegate tasks to specialized subagents
- `SkillsToolset`: Load and use [agent skills](https://www.anthropic.com/engineering/equipping-agents-for-the-real-world-with-agent-skills) from markdown files
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assuming (some of) these can be used stand-alone, without the rest of the Deep Agent framework, would it be possible to extract these into separate packages, that we can consider for upstreaming once they've matured a bit?

If they are usable standalone, even if they're still in the same package, I also wouldn't mind subheadings so that it's easier for a user to find "Todo Toolset" or "File system Toolset" in the sidebar ToC if they just want that bit.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it makes sense to have the explanation of your framework in the multi-agent-... page, and then here have a separate section for each of the stand-alone-usable toolsets, that can say "Part of ..." linking to the Deep Agent doc.

Those sections should be more generic, less marketing copy, just saying things like "File system access is useful because blablabla. Check out these implementations by the community:", as they may have multiple links, e.g. also https://pypi.org/project/pydantic-ai-filesystem-sandbox/.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestion. I've analyzed the toolsets for extractability:

Easy to extract:

  • TodoToolset
  • SkillsToolset

Would require more work:

  • FilesystemToolset - tightly coupled to the BackendProtocol abstraction layer
  • SubAgentToolset - dynamically imports other toolsets and is coupled to DeepAgentDeps

I'll look into extracting TodoToolset and SkillsToolset as separate packages first. Need to think through the API design and whether to keep them compatible with pydantic-deep or make them fully independent. Will follow up once I have a plan.

In the meantime, I can add subheadings for each toolset in the docs for better discoverability in the sidebar.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to have headings under "Third-Party Toolsets" (after MCP Servers, before Langchain) for each type of common toolset that has one or more community implementations and then in that section list each option, i.e. "Task Management"/Todos", "Filesystem" (https://pypi.org/project/pydantic-ai-filesystem-sandbox/ + yours once it's available), "Memory", "Code Execution" (could list https://github.com/pydantic/mcp-run-python), etc.

The ones that Pydantic-Deep covers can then have an item saying something to the effect of "The third-party Pydantic-Deep deep agent framework includes a FilesystemToolset among others"

That way it'll be easier to discover for users, not being nested under the not-necessarily-related-seeming Deep Agents heading, and leaves room for more future community alternatives.

The copy on the Multi-Agent page can then be the main place where that concept is introduced + Pydantic-Deep is mentioned more clearly, as I don't think a "Deep Agents/Pydantic-Deep" heading necessarily makes sense on the Toolsets page. I also wouldn't be opposed to a new page like https://starlette.dev/third-party-packages/ listing Third Party packages explicitly; that's also where https://github.com/jagreehal/pydantic-ai-guardrails could go for example.


The framework also includes multiple backends (in-memory, filesystem, Docker sandbox), automatic conversation summarization, and human-in-the-loop approval workflows.

See the [documentation](https://vstorm-co.github.io/pydantic-deepagents/) for installation and usage, or explore the [full demo application](https://github.com/vstorm-co/pydantic-deepagents/tree/main/examples/full_app) for a complete example with a chat interface, file uploads, skills, and streaming responses.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The path has a risk of getting outdated, so let's not include it.