Harness 与 Agent 工程 · Agent架构与协作 · 2025-11-25

用 Eino ADK 构建你的第一个 AI 智能体:从 Excel Agent 实战开始

Excel Agent 帮你告别繁琐的Excel操作,让数据处理自动化高效完成!

核心内容:

  1. Excel Agent 的核心功能与架构解析
  2. 基于 Eino ADK 构建智能体的实战步骤
  3. 典型业务场景与自动化收益展示

本文将会向您介绍如何利用 Eino ADK (Agent Development Kit) 构建一个强大的多智能体系统。

往期链接:Eino ADK:一文搞定 AI Agent 核心设计模式,从0到1搭建智能体系统

以 Excel Agent 这个实际业务场景为基础,Excel Agent 是一个能够“听懂你的话、看懂你的表格、写出并执行代码”的智能助手。它把复杂的 Excel 处理工作拆解为清晰的步骤,通过自动规划、工具调用与结果校验,稳定完成各项Excel数据处理任务。

接下来我们将从 Excel Agent 的完整架构与功能出发,向您展示该 Agent 是如何通过 Eino ADK 逐步搭建的,进而深入浅出的理解 Eino ADK 的核心设计特点,助您快速上手 Eino ADK,向构建自定义智能体与 AI 应用系统更进一步。

点击原文即可获取本示例完整代码链接,您可以随时浏览与下载。

Excel Agent 是什么?

Excel Agent 是一个“看得懂 Excel 的智能助手”,它先把问题拆解成步骤,再一步步执行并校验结果。它能理解用户问题与上传的文件内容,提出可行的解决方案,并选择合适的工具(系统命令、生成并运行 Python 代码、网络查询等等)完成任务。

Excel Agent 整体是基于 Eino ADK 实现的 Multi-Agent 系统,完整架构如下图所示:

Excel Agent 内部包含的几个 Agent 功能分别为:

Excel Agent 的典型使用场景

在真实业务里,你可以把 Excel Agent 当成一位“Excel 专家 + 自动化工程师”。当你交付一个原始表格和目标描述,它会给出方案并完成执行:

Excel Agent 的完整运行动线为:

核心收益:

Excel Agent 既可以单独使用,也可以作为子 Agent,集成在一个复合的多专家系统中,由外部路由到此 Agent 上,解决 excel 领域相关的问题。

下面我们将逐步拆解 Excel Agent,深入了解 Eino ADK 的核心设计特点,以及如何利用这些特点构建高效、灵活的 AI 应用系统。

ChatModelAgent:与 LLM 交互的基石

ChatModelAgent是 Eino ADK 中的一个核心预构建的 Agent,内部使用了 ReAct[1]模式(一种让模型‘思考-行动-观察’的链式推理模式):

ChatModelAgent旨在让 ChatModel 进行显式的、一步一步的“思考”,结合思考过程驱动行动,观测历史思考过程与行动结果继续进行下一步的思考与行动,最终解决复杂问题:

在 Excel Agent 中,每个 Agent 的核心都是这样一个ChatModelAgent,以 Executor 运行【读取用户输入表格的头信息】这个步骤为例 ,我们可以通过观察完整的运行过程来理解 ReAct 模式在ChatModelAgent中的表现:

  1. Executor:经过判断,将任务转交给 CodeAgent 运行
  2. CodeAgent:接收到任务【读取用户输入表格的头信息】
  1. 运行完成,将表格头信息返回给 Executor

Plan-Execute Agent:基于「规划-执行-反思」的多智能体协作框架

Plan-Execute Agent 是 Eino ADK 中一种基于「规划-执行-反思」范式的多智能体协作框架,旨在解决复杂任务的分步拆解、执行与动态调整问题。它通过 Planner(规划器)、Executor(执行器)和 Replanner(重规划器) 三个核心智能体的协同工作,实现任务的结构化规划、工具调用执行、进度评估与动态 replanning,最终达成用户目标:

// 完整代码: https://github.com/cloudwego/eino/blob/main/adk/prebuilt/planexecute/plan_execute.go// NewPlanner creates a new planner agent based on the provided configuration.func NewPlanner(_ context.Context, cfg *PlannerConfig) (adk.Agent, error)// NewExecutor creates a new executor agent.func NewExecutor(ctx context.Context, cfg *ExecutorConfig) (adk.Agent, error)// NewReplanner creates a new replanner agent.func NewReplanner(_ context.Context, cfg *ReplannerConfig) (adk.Agent, error)// New creates a new plan-execute-replan agent with the given configuration.func New(ctx context.Context, cfg *Config) (adk.Agent, error)

而 Excel Agent 的核心能力恰好为【解决用户在 excel 领域的问题】,与该智能体协作框架定位一致:

Planner 和 Replanner 会将用户模糊的指令拆解为清晰的、可执行的步骤清单,即包含多个步骤(Step)的计划(Plan),Eino ADK 为此提供了灵活的 Plan 接口定义,支持用户自定义 Plan 结构与细节:

type Plan interface { // FirstStep returns the first step to be executed in the plan. FirstStep() string // Marshaler serializes the Plan into JSON. // The resulting JSON can be used in prompt templates. json.Marshaler // Unmarshaler deserializes JSON content into the Plan. // This processes output from structured chat models or tool calls into the Plan structure. json.Unmarshaler}

默认情况下,框架会使用内置的 Plan 结构作为兜底配置,例如下面就是 Excel Agent 产生的一个完整运行计划:

### 任务计划- [x] 1. Read the contents of '模拟出题.csv' from the working directory into a pandas DataFrame.- [x] 2. Identify the question type (e.g., multiple-choice, short-answer) for each row in the DataFrame.- [x] 3. For non-short-answer questions, restructure the data to place question, answer, explanation, and options in the same row.- [x] 4. For short-answer questions, merge the answer content into the explanation column and ensure question and merged explanation are in the same row.- [x] 5. Verify that all processed rows have question, answer (where applicable), explanation, and options (where applicable) in a single row with consistent formatting.- [x] 6. Generate a cleaned report presenting the formatted questions with all relevant components (question, answer, explanation, options) in unified rows.

Workflow Agents:可控的多 Agent 运行流水线

Excel Agent 中,存在一些需要按照特定顺序运行 agent 的情况:

  1. 顺序运行:先运行 Planner,再运行 Executor 和 Replanner;Planner 只运行一次。
  2. 循环运行:Executor 和 Replanner 需要按需循环运行多次,每次循环运行都是先运行 Executor 后运行 Replanner
  3. 顺序运行:Plan-Executor 整体运行完后,固定运行一次 ReportAgent 进行总结。

对于这些拥有固定执行流程的场景,Eino ADK 提供了三种流程编排方式,协助用户快速搭建可控的工作流:

import github.com/cloudwego/eino/adk// 依次执行 制定研究计划 -> 搜索资料 -> 撰写报告sequential := adk.NewSequentialAgent(ctx, &adk.SequentialAgentConfig{ Name: "research_pipeline", SubAgents: []adk.Agent{ planAgent, // 制定研究计划 searchAgent, // 搜索资料 writeAgent, // 撰写报告 },})
import github.com/cloudwego/eino/adk// 循环执行 5 次,每次顺序为:分析当前状态 -> 提出改进方案 -> 验证改进效果loop := adk.NewLoopAgent(ctx, &adk.LoopAgentConfig{ Name: "iterative_optimization", SubAgents: []adk.Agent{ analyzeAgent, // 分析当前状态 improveAgent, // 提出改进方案 validateAgent, // 验证改进效果 }, MaxIterations: 5,})
import github.com/cloudwego/eino/adk// 并发执行 情感分析 + 关键词提取 + 内容摘要parallel := adk.NewParallelAgent(…
— 以上为试看内容(约 40%),开通会员后阅读全文 —

原文出处:https://www.53ai.com/news/neirongchuangzuo/2025112505917.html