# a2a-patterns **Repository Path**: yuxink/a2a-patterns ## Basic Information - **Project Name**: a2a-patterns - **Description**: No description available - **Primary Language**: JavaScript - **License**: Not specified - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-11-20 - **Last Updated**: 2026-11-20 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # A2A Patterns > **A2A Agent-to-Agent 智能体通信工程模式完全手册** — 全网最通俗、最全面、带图解、带可运行 Demo 的 A2A 实战文档站。 > > The complete field guide to agent-to-agent communication: plain-language explanations, hand-drawn diagrams, production patterns and runnable demos. 在线站点 / Live site: **https://yuxinrun.github.io/a2a-patterns/** - 中文(默认):`/` - English: `/en/` - 全站一键切换语言、自动明暗主题、手机 / 平板 / PC 自适应 --- ## 这是什么 一个用 **VitePress** 构建的双语技术手册,把 A2A(Agent-to-Agent)从「协议字段」讲到「企业落地」。内容参考 A2A 官方规范(Linux Foundation)、Anthropic 多智能体实践、OpenAI Agent 设计指南与 MCP 规范,但写法刻意避开学术腔: - 每章都有:**通俗解释 → 类比故事 → 示意图 → 技术原理 → 避坑指南 → 实战 Demo** - 大量手写 SVG/CSS 图解:架构图、流程图、时序图、生命周期图、对比矩阵(不依赖图表库,明暗主题都清晰) - 所有 Demo 只依赖 `fastapi` / `uvicorn` / `httpx`,复制即可运行 - 所有复杂概念配「人话翻译」区块 ## 生态矩阵 四站分工明确,构成一套完整的企业 AI 技术栈: | 站点 | 定位 | 地址 | | --- | --- | --- | | **better-agent** | Agent 调度、记忆、技能编排 | https://yuxinrun.github.io/better-agent/ | | **a2a-patterns** | Agent 横向通信(本仓库) | https://yuxinrun.github.io/a2a-patterns/ | | **mcp-patterns** | Agent 工具调用(MCP) | https://yuxinrun.github.io/mcp-patterns/ | | **llm-gateway-patterns** | 模型流量、限流、成本与合规 | https://yuxinrun.github.io/llm-gateway-patterns/ | ```text 调度与记忆 横向协作 纵向工具 模型流量 better-agent ─────▶ a2a-patterns ─────▶ mcp-patterns ─────▶ llm-gateway-patterns ``` ## 目录(13 章) | # | 章节 | 你会得到什么 | | --- | --- | --- | | 00 | [开篇导论](https://yuxinrun.github.io/a2a-patterns/intro/) | A2A 是什么、为什么非有不可、四件套关系图 | | 01 | [核心概念](https://yuxinrun.github.io/a2a-patterns/concepts/) | 对等协作 vs 垂直调用、六条红线 | | 02 | [官方架构](https://yuxinrun.github.io/a2a-patterns/architecture/) | 四层架构、Agent Card、发现、Mandates、上下文交接 | | 03 | [任务生命周期](https://yuxinrun.github.io/a2a-patterns/lifecycle/) | 六种状态、长任务、中途变更、HITL、协商 | | 04 | [通信协议](https://yuxinrun.github.io/a2a-patterns/protocol/) | Message/Part/Artifact、SSE、三种传输、错误与幂等 | | 05 | [A2A vs MCP](https://yuxinrun.github.io/a2a-patterns/vs-mcp/) | 十种场景选型、混合架构、最贵的误区 | | 06 | [七种工程模式](https://yuxinrun.github.io/a2a-patterns/patterns/) | 点对点、编排、分层、广播、故障转移、多租户、隐私 | | 07 | [安全与权限](https://yuxinrun.github.io/a2a-patterns/security/) | 身份、scope、mandate 链、越权与串话防护 | | 08 | [实战 Demo](https://yuxinrun.github.io/a2a-patterns/demos/) | 双向通信、流式、发现、LangGraph、CrewAI | | 09 | [生产踩坑](https://yuxinrun.github.io/a2a-patterns/pitfalls/) | 串话、超时、乱序、权限、大工件、并发 | | 10 | [性能与高并发](https://yuxinrun.github.io/a2a-patterns/performance/) | 连接池、缓存节流、集群优化、熔断 | | 11 | [企业级案例](https://yuxinrun.github.io/a2a-patterns/cases/) | 五个可复盘的落地案例 | | 12 | [未来生态](https://yuxinrun.github.io/a2a-patterns/future/) | Agent 网络、自主组队、闭环、AI OS | | — | [术语表](https://yuxinrun.github.io/a2a-patterns/glossary/) · [延伸阅读](https://yuxinrun.github.io/a2a-patterns/reading/) | 速查与原始资料 | 英文镜像与中文页面**锚点完全一致**,方便中英对照阅读。 ## 技术栈 | 能力 | 实现 | | --- | --- | | 文档框架 | VitePress 1.6(Vue 3 + Vite) | | 主题 | 自定义设计系统(`docs/.vitepress/theme/style.css`),对齐 better-agent 品牌 | | 字体 | Manrope Variable + JetBrains Mono Variable(本地打包,无外部请求) | | 双语 | `locales`:`root`(zh-CN)+ `en`,导航/侧边栏/首页/404 全部双语 | | 图解 | 自研 Vue 组件:`flow` / `layers` / `sequence` / `lifecycle` / `compare` / `hub` / `matrix` | | 搜索 | 构建期生成 `search-index.json` + 自研 CJK 友好搜索框(`⌘K` / `Ctrl+K`) | | 导航 | 面包屑、章节下拉、上一章/下一章、返回顶部、生态侧栏 | | 代码 | Vitesse 明暗主题、行号、一键复制 | | 部署 | GitHub Actions → GitHub Pages(base `/a2a-patterns/`) | ## 本地开发 ```bash npm install npm run dev # http://localhost:5173/a2a-patterns/ ``` ```bash npm run build # 生成搜索索引 + 构建静态站点 npm run preview # 本地预览构建产物 ``` 构建产物在 `docs/.vitepress/dist`。 ## 项目结构 ```text a2a-patterns/ ├── docs/ │ ├── .vitepress/ │ │ ├── config.mts # base、locales、导航、侧边栏、sitemap │ │ ├── data/ │ │ │ ├── catalog.ts # 13 章目录中枢(侧边栏/面包屑/章节地图共用) │ │ │ ├── ecosystem.ts # 四站生态矩阵 │ │ │ └── diagrams.ts # 图解数据(双语) │ │ └── theme/ │ │ ├── index.ts # 扩展默认主题 │ │ ├── Layout.vue # 插槽:搜索、面包屑、页脚、返回顶部 │ │ ├── style.css # 设计系统 │ │ ├── components/ # 搜索、面包屑、生态卡、章节地图、图解组件 │ │ └── composables/ # useLang(isEn / t) │ ├── intro/ concepts/ architecture/ lifecycle/ protocol/ vs-mcp/ │ ├── patterns/ security/ demos/ pitfalls/ performance/ cases/ future/ │ ├── glossary/ reading/ start/ │ ├── en/ # 英文镜像(目录结构一致) │ └── public/ # A2A logo/favicon/hero SVG、作者品牌图、搜索索引 ├── scripts/build-search.mjs # 构建期切分 Markdown 生成搜索索引 └── .github/workflows/deploy.yml ``` ## 内容约定 1. **能跑优先**:Demo 只依赖三个 Python 包,复制即可运行。 2. **区分事实与判断**:协议字段是事实;参数建议是判断,并标注适用条件。 3. **说清代价**:每种模式都写代价,不做单方面推荐。 4. **不追新词**:只写能落到「任务、状态、工件、错误码」上的概念。 ## 部署 推到 `main` 分支即自动部署。首次需要在仓库 **Settings → Pages → Build and deployment → Source** 选择 **GitHub Actions**。 ## 作者 **鱼心快跑** — 鱼心快跑,Bug追不到 · https://yuxin.run ## License MIT © 2026 Yuxin