Skip to content

Conversation

Copy link

Copilot AI commented Dec 7, 2025

Implements Agent-to-Agent (A2A) protocol support enabling BotSharp to communicate with remote agents through standardized interfaces, replacing direct HTTP calls with semantic routing and bidirectional async communication.

Implementation

Core Services

  • A2AClient: Manages remote agent invocations with async callback support
  • A2ACardResolver: Fetches and parses agent capability cards from remote endpoints
  • AgentRegistry: Semantic agent discovery with natural language queries and confidence scoring

Integration

  • A2AAgentHook: Injects discovered A2A agents into routing pipeline at instruction load time
  • Two functions: QueryAgentRegistryFn for semantic search, InvokeA2AAgentFn for remote invocation

Protocol

  • Agent cards exposed at /a2a/card describe capabilities and parameters
  • Invocations sent to /a2a/invoke with conversation context
  • Progress notifications pushed to configured callback endpoint

Usage

Query registry semantically:

var query = new AgentRegistryQuery { Query = "谁擅长处理税务计算?" };
var result = await registry.QueryAgentsAsync(query);
// Returns matching agents with confidence scores

Invoke remote agent with async support:

var request = new A2AInvokeRequest
{
    AgentId = "tax-agent",
    Parameters = new Dictionary<string, object> { ["income"] = 50000 },
    Context = dialogs
};
var response = await a2aClient.InvokeAgentAsync(request);

if (response.IsAsync)
{
    a2aClient.RegisterProgressCallback(response.RequestId, notification =>
    {
        Console.WriteLine($"Progress: {notification.Progress}%");
    });
}

Configuration

{
  "AgentProtocol": {
    "EnableA2AClient": true,
    "RegistryEndpoint": "https://registry.example.com/api",
    "CallbackEndpoint": "https://botsharp.example.com/api/a2a/callback",
    "RemoteAgents": {
      "agent-id": "https://remote-agent.example.com"
    }
  }
}

Router automatically discovers and routes to A2A agents without code changes. Falls back to standard routing on failure.

Original prompt

在.NET 环境中,Microsoft 提供了 A2A 的 SDK ,使用BotSharp 的插件机制实现下列要求。
BotSharp 作为 A2A Client: Router Agent 不再直接调用 HTTP 接口,而是调用 A2AClient。它首先通过 A2ACardResolver 解析远程 LangGraph Agent 的名片,理解其能力。
语义路由: 这使得 BotSharp 的路由可以变得更加动态。Router 可以查询企业内部的 Agent 注册中心(Registry),询问“谁擅长处理税务计算?”,注册中心返回匹配的 A2A Agent 列表,Router 再动态选择最佳节点进行连接。
双向通信: A2A 支持异步回调和推送通知。这意味着 LangGraph 超级节点在处理长时任务(如运行数小时的数据分析)时,可以主动通过 A2A 协议向 BotSharp 推送进度更新或最终结果,而无需 BotSharp 轮询


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 4 commits December 7, 2025 14:01
Co-authored-by: geffzhang <439390+geffzhang@users.noreply.github.com>
Co-authored-by: geffzhang <439390+geffzhang@users.noreply.github.com>
Co-authored-by: geffzhang <439390+geffzhang@users.noreply.github.com>
Co-authored-by: geffzhang <439390+geffzhang@users.noreply.github.com>
Copilot AI changed the title [WIP] Add A2A client functionality using BotSharp Implement A2A protocol plugin for agent-to-agent communication Dec 7, 2025
Copilot AI requested a review from geffzhang December 7, 2025 14:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants