返回首页

来自微软的 Agent Framework,用于智能体

微软 Agent Framework — 基于 Semantic Kernel 开发多智能体系统的框架。支持移交编排、工具集成,以及在低资源设备上的部署。研究者智能体和工作流的代码示例。

智能体新时代:微软 Agent Framework
Advertisement 728x90

Microsoft Agent Framework:多代理系统框架

微软推出了 Agent Framework——一个用于构建代理式应用(包括多代理架构)的开源框架。它是 Semantic Kernel 的演进版,同时也是 AutoGen 的继任者。该框架支持从共享请求池中构建代理图,实现并行和顺序任务执行。

框架的主要特性

Agent Framework 专为轻量级开发而设计。代理可以集成如网络搜索等工具,并组织成工作流。它支持移交编排:一个代理根据条件将控制权移交给另一个代理,完成后返回控制权。

主要特性:

Google AdInline article slot
  • 代理图:顺序和并行执行。
  • 工具集成:使用 AIFunctionFactory 连接外部 API。
  • 内存和状态:支持 SQLite 存储上下文。
  • 事件:事件发射用于工作流监控。

该框架适用于边缘设备:测试显示,它可以在 Raspberry Pi 3B 上运行 Telegram 机器人、SQLite 内存和五个代理,而无明显延迟。

使用工具创建代理

代理通过 ChatClientAgent 配置。以下是带网络搜索的研究员代理示例:

var researcher = new ChatClientAgent(chatClient,
    new ChatClientAgentOptions
    {
        Name = "Researcher",
        Description = "Web search, real-time information, weather, news, and general knowledge.",
        ChatOptions = new ChatOptions
        {
            Instructions = "Search the web for any real-time information",
            Tools = [ AIFunctionFactory.Create(webSearchTools.Search),]
        }
    });

在此,代理接收指令和工具,用于处理最新信息的请求。

Google AdInline article slot

通过移交进行编排

对于多代理工作流,使用 AgentWorkflowBuilder。分流代理分发任务,移交定义转换。

var workflow = AgentWorkflowBuilder
    .CreateHandoffBuilderWith(triage)
    .WithHandoffs(triage, [clerk, archivist, secretary, researcher])
    .WithHandoff(researcher, triage, "Hand back to Triage when done or if the request is not about search/information.")
    .WithHandoff(...)
    .EmitAgentResponseEvents(true)
    .Build();

这种方法最大限度降低了复杂性:每个代理专注于自身角色,对于无关请求将控制权交回分流代理。

实际应用

该框架已在家庭 AI 助手场景中进行了测试:

Google AdInline article slot
  • 通过 Telegram 机器人进行交互。
  • 使用 SQLite 保存上下文的内存。
  • 五个代理:分流代理、文员、档案管理员、秘书、研究员。
  • 部署在 Raspberry Pi 3B 上——稳定运行无过载。

此配置展示了在物联网和低资源环境下的可扩展性。

关键要点

  • Agent Framework 通过添加原生多代理支持,演进自 Semantic Kernel。
  • 移交机制无需自定义代码即可简化编排。
  • 轻量级:在 Raspberry Pi 等 ARM 设备上运行完整多代理堆栈。
  • 开源,可自定义工具和工作流。
  • 事件发射,用于与可观测性系统集成。

— Editorial Team

Advertisement 728x90

继续阅读