kbs_agent_a2a 智能体协议适配中间件
kbs_agent_a2a is an early-stage Python project in the AI payments / x402 ecosystem, focused on a2a, a2a-protocol, agent-to-agent, agents. It currently has 13 GitHub stars and 1 forks, and sits alongside related tools like a2a-go, LeapRAG, a2a-x402, lucid-agents, agentanycast, sentrix.
基于谷歌开源A2A协议的多框架智能体互操作性适配层实现
KBS_Agent_A2A 是一个协议适配中间件(Protocol Adaptation Middleware),专注于实现谷歌开源的 Agent2Agent (A2A) 协议标准。该项目旨在解决不同AI框架和厂商构建的智能体之间的互操作性问题,提供标准化的通信接口和数据交换格式。
本项目基于以下谷歌官方资源开发:
A2A协议官方文档:https://google.github.io/A2A/#/documentation
A2A参考实现:https://github.com/google/A2A
我们的项目在这些基础上进行了扩展,实现了针对RagFlow和Dify等框架的协议适配。
目前,本项目实现了以下框架的A2A协议适配:
RagFlow是一个专注于检索增强生成(Retrieval-Augmented Generation, RAG)的框架,主要功能是将大型语言模型与外部知识库结合,提升生成内容的准确性和相关性。本项目通过API规范化和协议封装,使RagFlow能够与其他支持A2A协议的系统进行标准化通信。
Dify是一个开源的LLMOps(大语言模型运维)平台,提供可视化的AI应用构建工具和运行环境。我们计划进行跨平台协议兼容工作,使Dify能够通过A2A协议与其他智能体系统进行标准化交互。
项目采用模块化设计,主要包含三个核心部分:
common: 共享基础设施,实现协议抽象层(Protocol Abstraction Layer)
agents: 智能体服务器实现,适配器模式(Adapter Pattern)应用
hosts: 客户端应用实现,作为互操作性桥接器(Interoperability Bridge)
pip install -e .
我们提供了简便的启动脚本来运行服务器和客户端:
# 使用默认设置启动服务器(localhost:10003)
python start_server.py
# 指定主机和端口
python start_server.py 192.168.1.100:8080
# 指定聊天ID和RagFlow API URL
python start_server.py localhost:10003 --chat-id=abc123 --url=https://api.example.com
# 连接到默认服务器(localhost:10003)
python start_client.py
# 连接到指定服务器
python start_client.py http://192.168.1.100:8080
您也可以直接使用Python模块启动:
python -m agents.ragflow
python -m hosts.kbs_cli --ragflow http://localhost:10003
A2A(Agent2Agent)是谷歌推出的开源协议,旨在解决企业AI采用过程中不同框架和厂商构建的智能体之间的互操作性问题。该协议提供了一种标准化的方式,使智能体能够:
/.well-known/agent.json),包含名称、描述、URL、支持的输入/输出模式、技能列表等tasks/send: 发送任务请求tasks/sendSubscribe: 发送任务并建立流式事件订阅tasks/get: 获取任务状态和结果tasks/cancel: 取消正在进行的任务tasks/pushNotification/set: 配置推送通知tasks/pushNotification/get: 获取推送通知配置tasks/resubscribe: 重新订阅之前的任务流TaskStatusUpdateEvent和TaskArtifactUpdateEvent形式发送A2A协议中,会话、任务和消息形成了多级嵌套的层次结构:
Session (会话)
└── Task (任务) - 可以有多个
├── Message (消息) - 可以有多个
│ └── Part (部分) - 每个消息可以有多个部分
└── Artifact (构件) - 可以有多个
└── Part (部分) - 每个构件可以有多个部分
这种结构支持多种使用模式:
在实际应用中:
sessionId字段关联多个任务A2A协议注重"会话(Session)"而非"用户(User)",使系统能够在不要求显式用户注册的情况下,通过会话ID维护状态和上下文连贯性。
这些组件共同构成了一个完整、灵活且安全的智能体通信生态系统,为企业级AI应用提供了标准化的互操作性解决方案。
服务器运行时需要设置以下环境变量:
| 环境变量 | 描述 | 必需 |
|---|---|---|
| RAGFLOW_API_KEY | RagFlow API密钥,用于身份验证 | 是 |
| RAGFLOW_API_URL | RagFlow API基础URL | 是 |
| chat_assistants | 聊天助手ID(优先使用命令行参数) | 否 |
您可以在项目根目录或agents/ragflow目录下创建.env文件来设置这些变量:
RAGFLOW_API_KEY=your_api_key_here
RAGFLOW_API_URL=https://api.ragflow.ai
chat_assistants=chat_id1,chat_id2
本项目代表了AI系统集成领域的重要工作:
欢迎贡献代码、报告问题或提出新功能建议。请阅读贡献指南了解详情。
联系我们:kbs@tsingturing.com
本项目采用 Apache License 2.0 开源协议。
本项目基于以下资源开发,特此感谢:
Golang SDK for A2A Protocol
LeapRAG is an open-source platform that integrates advanced RAG technology with Google’s A2A protocol, enabling users to build context-aware, data-driven agents. These agents are automatically A2A-compliant and can be discovered and used by any compatible client without extra development.
The A2A x402 Extension brings cryptocurrency payments to the Agent-to-Agent (A2A) protocol, enabling agents to monetize their services through on-chain payments. This extension revives the spirit of HTTP 402 "Payment Required" for the decentralized agent ecosystem.
Lucid Agents Commerce SDK. Bootstrap AI agents in 60 seconds that can pay, sell, and participate in agentic commerce supply chains. Our protocol agnostic SDK provides CLI-generated templates and drop-in adapters for Hono, Express, Next.js, and TanStack, giving you instant access to crypto/fiat payment rails (AP2, A2A, x402, ERC8004).
Connect AI agents across any network — zero config, encrypted, skill-based routing
Autonomous Agentic Coordination Framework (WIP)
A local-first AI agent with persistent memory, emotional intelligence, and a peer-to-peer skills economy.
The trust layer for agent-to-agent commerce — natural-language mandates, ERC-7710 delegated permissions, x402 payments, escrow, and dispute resolution as one open, catch-all Agent Skill / Claude Code plugin.
Agent behavior that compiles
Aser is a lightweight, self-assembling AI Agent frame.
A small, powerful, open-source CLI coding agent that works with open models.
Beacon - agent-to-agent pings with optional RTC value attached (BoTTube/Moltbook/RustChain + UDP bus)