@QingQ77: 把 Pydantic AI 智能体跑过的追踪日志变成一张交互式流程图,用户请求、模型调用、用了什么工具、调了哪个子智能体、花了多少 Token 和多少钱,一目了然。 https://github.com/vstorm-co/agentca…
摘要
agentcanvas 是一个 Python 工具,能将 Pydantic AI 智能体在 Logfire 中的追踪日志转换为交互式流程图,清晰展示模型调用、工具使用、子智能体、Token 消耗和成本等完整工作流信息。
查看缓存全文
缓存时间: 2026/06/16 19:41
把 Pydantic AI 智能体跑过的追踪日志变成一张交互式流程图,用户请求、模型调用、用了什么工具、调了哪个子智能体、花了多少 Token 和多少钱,一目了然。
https://github.com/vstorm-co/agentcanvas…
一个 Python 工具,读 Logfire 里的追踪数据,渲染成交互式 HTML 图表。主流程按 User → Agent → 模型调用 → 工具 → Answer 的序列展示,子智能体可以递归嵌套展开。
vstorm-co/agentcanvas
Source: https://github.com/vstorm-co/agentcanvas
agentcanvas
See exactly how your AI agent works.
Turn Pydantic AI runs logged to Logfire into a polished, animated diagram of the whole workflow —
every model call, tool, nested sub-agent, token and dollar.
Features · Quick start · How it works · Architecture · Contributing
![]() Click any node for a full inspector — tokens, exact cost, reasoning, the tools the model could call. |
![]() The full multi-turn conversation, with tool calls and reasoning. |
![]() Per-tool input, output and timing. |
![]() A guided tour (auto or manual) narrates each step for client demos. |
Why
Clients rarely understand what an “AI agent” actually does. They see a prompt and an answer — not the reasoning, the tool calls, the sub-agents, or the cost. agentcanvas reads the trace your agent already sends to Logfire and renders it as a clear, interactive block diagram you can put on screen in a meeting: this is the question, here is what the model decided, these are the tools it ran, this is what each step cost, and here is the answer.
✨ What it shows
| 🧩 Block diagram | The full run as a flow: User → Agent → model call → tools → model call → answer, on a pan / zoom / drag canvas. |
| 🪆 Nested agents | When a tool is itself another agent (with its own tools), it is drawn as a nested frame — recursively, to any depth. The diagram grows with the system. |
| 💬 Full conversation | Every turn is its own frame, connected in sequence. A side panel shows the complete user → assistant → user → assistant transcript. |
| 🧠 Reasoning | The model's "thinking" summary and reasoning-token counts, shown on each model call and in the transcript. |
| 💰 Exact cost | Per model call and for the whole run, computed from tokens via genai-prices. |
| 🔢 Token usage | Input / output / reasoning tokens, per step and aggregated. |
| 🔎 Deep detail | Provider, finish reason, response id, the tools available to the model (with descriptions), output mode and thinking config — in a click-through, resizable inspector. |
| 🎬 Guided tour | An auto walkthrough and a manual step mode (Space / click / arrows, with back), each with plain-language narration for client demos. |
| 📦 Self-contained | The output is a single HTML file — no server, no build, works offline, easy to send. |
🚀 Quick start
pip install agentcanvas
Set LOGFIRE_READ_TOKEN in your environment (or a .env file), then build the
report from your latest agent run:
agentcanvas # latest run → agent_flow.html (opens in browser)
agentcanvas --list # list recent runs
agentcanvas --trace-id <id> # a specific run
agentcanvas -o report.html --no-open
Or use it as a library:
from agentcanvas import LogfireClient, parse_run, render_html
client = LogfireClient() # reads LOGFIRE_READ_TOKEN
trace_id = client.latest_trace_id()
report = parse_run(client.fetch_trace(trace_id), trace_id)
open("report.html", "w").write(render_html(report))
| Variable | Used for |
|---|---|
LOGFIRE_READ_TOKEN | reading traces via the Logfire Query API (required) |
LOGFIRE_BASE_URL | optional region override (default US; EU: https://logfire-eu.pydantic.dev) |
LOGFIRE_WRITE_TOKEN | the example agent sending telemetry to Logfire |
OPENROUTER_API_KEY | the example agent (model via OpenRouter) |
Try the example agent
The repo ships a runnable example (assets/scripts/main.py) — a thinking agent with five tools,
a nested sub-agent and a multi-turn conversation. From a checkout:
uv sync --all-extras --prerelease=allow # installs the `demo` extra
uv run --prerelease=allow python assets/scripts/main.py # generates a sample trace in Logfire
agentcanvas # visualize it
🔍 How it works
Logfire (OpenTelemetry GenAI spans) ──query──► parser ──► payload ──render──► agent_flow.html
Pydantic AI’s instrumentation emits OpenTelemetry GenAI spans (invoke_agent, chat,
execute_tool). agentcanvas reads them through the Logfire Query API (SQL + a read token),
rebuilds the span tree into a recursive workflow (turns → rounds → tools → nested agents), prices it
with genai-prices, and renders a single self-contained HTML report.
🏗️ Architecture
| Module | Role |
|---|---|
logfire_client.py | Logfire Query API client (SQL → rows) |
parser.py | span tree → recursive payload (turns, rounds, tools, nested agents) |
pricing.py | exact cost from tokens via genai-prices |
render.py | payload → embedded HTML / CSS / JS report |
viz.py | CLI entry point |
assets/scripts/main.py | demo agent: thinking, five tools, a nested sub-agent, a multi-turn conversation |
assets/scripts/make_demo.py · make_screenshots.py | record the demo video / capture doc screenshots |
Development
git clone https://github.com/vstorm-co/agentcanvas.git
cd agentcanvas
make install # uv sync (incl. dev tools)
make all # ruff + mypy + pytest
The library is fully typed and tested; make all must pass before a PR.
See CONTRIBUTING.md for details.
Changelog
See CHANGELOG.md.
License
MIT — see LICENSE.
相似文章
@wsl8297: 用 AI Agent 跑复杂任务,最难受的往往不是模型不够强,而是对话一变长,上下文就开始爆仓。 你还得一遍遍补背景、重讲流程,再加上工具调用吐出来的冗余日志,Token 像开了口子一样往外流。 最近看到腾讯开源的 TencentDB A…
腾讯开源了 TencentDB Agent Memory,通过分层记忆管理(符号化短期记忆+分层长期记忆)解决AI Agent长对话上下文爆仓问题,实测Token消耗最高降低61%,任务通过率提升超50%。
@LinearUncle: 推荐一个开源最强的本地跨 AI的session管理器:AgentsView。 它会把 Claude Code、Codex、Cursor 等工具的历史记录统一索引起来,让你快速搜索旧对话、查看项目记录、统计 token 和成本等。 全平台客…
AgentsView 是一个开源的本地跨 AI 会话管理器,能够统一索引 Claude Code、Codex、Cursor 等工具的历史记录,支持快速搜索、项目记录查看、token 和成本统计,并提供全平台客户端支持。
@justloveabit: 用这个开源工具,我让一群AI替我上班了 事情是这样的,最近一直在折腾各种AI agent。Claude Code开一堆窗口,Codex也在跑,偶尔还要用Cursor。结果呢,乱成一锅粥——哪个agent在干啥,花了多少钱,完全搞不清楚。重…
本文介绍了一款名为Paperclip的开源工具,用于统一管理和调度多个AI Agent。它通过模拟公司组织架构、任务分配与预算控制等功能,解决了多Agent协作时上下文丢失、成本不可控和调度混乱的痛点。
@GitHub_Daily: 用 AI 智能体生产级事情,写代码、跑流程、调接口,一开始还行,但规模一大就容易失控,权限太宽、上下文丢失、调试无从下手。 于是找到了 agents-best-practices 这套完整的智能体运行框架设计指南,不限于编码场景,运营、销…
介绍了 agents-best-practices 仓库,这是一份生产级 AI 智能体运行框架设计指南,涵盖工具权限分级、上下文压缩等,支持 Codex 和 Claude Code 安装。
@teach_fireworks: AI Coding 现在开始进入一个很有意思的阶段。 过去大家讨论最多的是模型能力、上下文长度、Agent Loop、Tool Use、自动化编程,但真正把 Agent 长时间放进真实开发环境之后,很多团队发现问题已经不只是“能不能生成代…
介绍开源工具 re_gent,它为 AI 编程 Agent 提供运行时级别的版本控制和可观测性基础设施,解决 Agent 长时间运行后的代码溯源与审计问题。



