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.0

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.0
File Size Uploaded Provenance
agentsdiagram-0.1.0.tar.gz 670.0 kB With provenance Details

Built distribution (wheel)

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

Total release size: 873.4 kB

Release files / agentsdiagram-0.1.0.tar.gz

Download URL agentsdiagram-0.1.0.tar.gz
Size 670.0 kB
Tags Source
SHA-256 checksum
How to use checksums
df6643cf7e275c81e1e481f6286a0a60aabd93839ec4af7535ccc3a6eafe6ee4
BLAKE2b-256 checksum
How to use checksums
97804806083b7519752c30937c65a89a9684cf86641d95e90a78453d5664d4a6
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.0-py3-none-any.whl

Download URL agentsdiagram-0.1.0-py3-none-any.whl
Size 203.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e711f84055c5fc116c88c2d586a040b42f10d1416767b81d7e4b584d6deed195
BLAKE2b-256 checksum
How to use checksums
0c2cc200d4a489acb0e7db8800c666b89c8a9c2045e5afcffe9a98cc2197f3cd
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.0

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.0.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