Skip to main content

agentsdiagram

See your AI agents. agentsdiagram reads the code of your PydanticAI and smolagents agents and draws them: agents, tools, toolsets, MCP servers, capabilities, delegation between agents, hand-off workflows and pydantic-graph flows.

It is static analysis: your code is parsed, never imported or executed. No API keys, no dependencies of your project, no network.

The interactive viewer

  • CLI: Mermaid, JSON or a self-contained interactive HTML page.
  • VS Code extension (also on Open VSX for Cursor, Windsurf and Positron): a live diagram next to your code that follows your edits, "Show in diagram" code lenses and diagnostics.

Quick start

uvx agentsdiagram scan path/to/project                    # Mermaid to stdout
uvx agentsdiagram scan . -f html -o agents.html           # interactive page, open it in any browser
uvx agentsdiagram scan . -f markdown -o AGENTS-DIAGRAM.md # renders on GitHub
uvx agentsdiagram check .                                 # diagnostics; exit 1 on errors (CI, pre-commit)

Or install it: uv tool install agentsdiagram / pip install agentsdiagram.

agentsdiagram scan [PATH] [-f mermaid|json|html|markdown] [-o FILE] [--framework pydantic_ai|smolagents]
                   [--include GLOB] [--exclude GLOB] [--title TEXT]
agentsdiagram check [PATH] [--strict] [--json]
agentsdiagram schema        # JSON Schema of the IR
agentsdiagram lsp           # language server (needs agentsdiagram[lsp]); used by the extension

Project-wide settings go in pyproject.toml:

[tool.agentsdiagram]
include = ["src/**"]
exclude = ["tests/**", "notebooks/**"]

What it understands

PydanticAI 2.x smolagents 1.x
Agents Agent(...), Agent.from_file("spec.yaml"), factories (make_agent()) CodeAgent, ToolCallingAgent
Tools @agent.tool, @agent.tool_plain, tools=[f, Tool(...)] @tool, Tool subclasses, default tools, add_base_tools
Toolsets FunctionToolset, wrappers (.prefixed(), .filtered()…), @agent.toolset ToolCollection, Hub/Space/LangChain sources
MCP MCPToolset(...), load_mcp_toolsets("mcp.json"), MCP(url=...) ToolCollection.from_mcp, MCPClient
Multi-agent agent run inside a tool, SubAgents, hand-off functions managed_agents=[...]
Flows pydantic-graph GraphBuilder (steps, decisions, joins) and BaseNode —
Checks v1 API still in use managed agents without name/description, @tool without hints, name clashes

Anything that only exists at runtime (lists built in a loop, tools fetched from a server) shows up as a dashed dynamic node instead of silently disappearing. Full coverage matrices: PydanticAI · smolagents.

VS Code extension

Install Agents Diagram from the Marketplace or Open VSX. It needs either uv (the extension runs uvx agentsdiagram[lsp]) or your own command in agentsdiagram.server.command. The Python extension is not required. See packages/vscode/README.md.

How it works

your code ──LibCST──▶ adapters (pydantic_ai, smolagents) ──▶ facts ──link──▶ IR (JSON)
                                                                         ├─▶ Mermaid
                                                                         ├─▶ HTML viewer (React Flow)
                                                                         └─▶ LSP ─▶ VS Code panel

The IR is a small, versioned JSON format (docs/ir.md); the viewer and the extension use TypeScript types generated from its JSON Schema. Architecture and design decisions: docs/architecture.md.

Roadmap

  • Plan (v0.3): draw agents and tools that do not exist yet; agentsdiagram writes the stubs.
  • Edit (v0.4): connect, add and remove tools and agents in the diagram; the change is written to your code with LibCST, preserving formatting. The code stays the single source of truth.
  • More frameworks through adapters (docs/adding-a-framework.md).

Development

uv sync                      # Python 3.11+, includes pydantic-ai and smolagents for the oracle tests
pnpm install && pnpm build   # viewer + extension (pnpm 11, Node 22+)
uv run pytest                # unit, snapshot, oracle, drift and LSP tests
pnpm test                    # viewer (vitest) + extension smoke test

More in docs/architecture.md and docs/releasing.md.

License

MIT © 2026 Alex Ojeda Copa

Metadata

Release files for agentsdiagram 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for agentsdiagram 0.1.2
File Size Uploaded Provenance
agentsdiagram-0.1.2.tar.gz 671.4 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for agentsdiagram 0.1.2
File Interpreter ABI Platform
agentsdiagram-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 874.9 kB

Release files / agentsdiagram-0.1.2.tar.gz

Download URL agentsdiagram-0.1.2.tar.gz
Size 671.4 kB
Tags Source
SHA-256 checksum
How to use checksums
f491e79f0211e6e2049f33058e7cfe52db804f34b70a7a2f2a00d691790cd44f
BLAKE2b-256 checksum
How to use checksums
7da0687965e9bda3f760e5cc4d2bcfb727c1be8196a81b6442e7e1a691f2736a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 22, 2026.

Transparency log

Release files / agentsdiagram-0.1.2-py3-none-any.whl

Download URL agentsdiagram-0.1.2-py3-none-any.whl
Size 203.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9f158f2b90c6a4cc08c75334c939bb0d5d6c80d1e61eac95d39de50a81a7d329
BLAKE2b-256 checksum
How to use checksums
c678e5b6e602ff52fac500060d7691a744e449e6f1e6446beb5ae29a684d546b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 22, 2026.

Transparency log

Security for agentsdiagram 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for agentsdiagram-0.1.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 22, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page