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, light theme

Dark theme

The interactive viewer, dark theme

Website and live demos: https://alex-roc.github.io/agentsdiagram/

  • 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

Try it on the two projects in examples/: a PydanticAI support desk and a smolagents research team (uvx agentsdiagram scan examples -f html -o examples.html).

In the HTML page and in VS Code: click a node to see its details and its neighbors, / to search, the legend to show or hide node kinds, Problems for what the analysis found, and the moon/sun button for the theme (VS Code follows your editor theme).

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

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.3
File Size Uploaded Provenance
agentsdiagram-0.1.3.tar.gz 726.5 kB With provenance Details

Built distribution (wheel)

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

Total release size: 934.9 kB

Release files / agentsdiagram-0.1.3.tar.gz

Download URL agentsdiagram-0.1.3.tar.gz
Size 726.5 kB
Tags Source
SHA-256 checksum
How to use checksums
ea8368fa987a24be088f5c9df2bde3b207215cd80cde1c67723e30cea1458558
BLAKE2b-256 checksum
How to use checksums
1848a667949c52120f9856aa14a0f12978f8fea03babbeaa5301cd8f36278395
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.3-py3-none-any.whl

Download URL agentsdiagram-0.1.3-py3-none-any.whl
Size 208.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
aeb30db153491cf53ff387a30b7b95f7c7cf5210602e7cc233a1db6399be3f55
BLAKE2b-256 checksum
How to use checksums
8aa30b0f9a4f41806af18946bf1ec0712f3484ffefb764a307bf39650ae93404
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.3

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