AI应用工程师 02
2026/6/27 3:12:38 网站建设 项目流程

概述

大模型缺陷Agent解决方案
只能聊天会执行任务
不会调用APITool Calling
不会长期记忆Memory
不会拆解任务Planning
不会纠错Reflection
不会跨系统操作Workflow
不会自主查资料Agentic RAG
不会使用软件Computer Use

用户:
分析上个月销售数据


Agent:

Step1 调SQL工具

Step2 获取数据

Step3 Pandas分析

Step4 生成图表

Step5 输出报告

一级方向二级技术解决问题难度
Tool AgentTool Calling调接口
Workflow AgentDAG多步骤任务⭐⭐
Planning AgentTask Decompose自动拆任务⭐⭐⭐
Memory AgentLong Memory长期记忆⭐⭐⭐
Reflection AgentSelf Correct自我纠错⭐⭐⭐
Multi-AgentAgent Team多角色协作⭐⭐⭐⭐
Agentic RAGAutonomous Retrieval自动检索⭐⭐⭐
Computer AgentGUI操作操作电脑⭐⭐⭐⭐⭐
Embodied AgentRobot Agent机器人⭐⭐⭐⭐⭐
Graph AgentKnowledge Graph推理关系⭐⭐⭐⭐
Code AgentCoding Agent写代码⭐⭐⭐
Data AgentBI Agent数据分析⭐⭐⭐
Web AgentBrowser Agent浏览网页⭐⭐⭐
MCP AgentMCP Protocol标准化工具⭐⭐⭐⭐

Tool Calling

对应你表里的:

  • Tool Agent ⭐

你要先搞清三件事:

  • LLM如何“决定调用工具”(function calling / tool schema)
  • 工具如何被注册(schema / prompt / JSON)
  • 工具执行链路(LLM → tool router → function → result → LLM)

目标产物:

  • 一个“能调用2~3个工具”的LLM系统
    例如:
    • 查天气
    • 查数据库
    • 调用HTTP接口

👉 没这个,后面所有 Agent 都只是“高级聊天”

什么是Tool Calling

让LLM拥有「感知外部世界」和「操作外部世界」的能力。

Q:北京天气?

LLM:

需要调用weather_tool

weather_tool("北京")

26℃

LLM
北京今天26℃...

为什么LLM会主动调用工具

LLM不会调用工具。

LLM只会:

预测下一个Token

Question:

北京天气

Tools:
weather_tool(city)

LLM预测:

{ "name":"weather_tool", "arguments":{ "city":"北京" } }
Function Calling原理

只是作为一个可以调用的json工具类集合给AI

AI在返回调用哪个

{ "name":"weather", "description":"查询天气", "parameters":{ "type":"object", "properties":{ "city":{ "type":"string" } } } }

模型看到

用户:

北京天气

工具:

weather

{

"name":"weather",

"arguments":{

"city":"北京"

}

}

模型并没有调用工具的能力,只是返回需要调用的工具和参数的json协议格式,由对应的来进行运行,可能是反射,可能是代理

Spring AI里面如何实现

SpringAI实际上帮你做了四件事情。

tool注册

@Bean ToolCallback weatherTool(){ return MethodToolCallback.builder() .object(weatherService) .method("query") .build(); }

SpringAI内部

/** * 工具注册中心 * 底层使用Map结构存储全部工具定义,维护工具名称与工具元数据的映射关系 * 核心职责:工具注册、工具查询、工具删除、遍历全部已注册工具 * K:toolName 工具唯一名称 * V:ToolDefinition 工具完整定义信息(入参、描述、执行逻辑、权限等) */ public class ToolRegistry { // 底层存储容器 /** * 工具映射表 * key:toolName 工具唯一标识名称,全局不可重复 * value:ToolDefinition 工具元定义对象,包含工具所有配置信息 */ private final Map<String, ToolDefinition> toolMap; // 构造器注释示例 /** * 初始化空的工具注册容器 */ public ToolRegistry() { this.toolMap = new HashMap<>(); } /** * 注册工具 * @param toolName 工具唯一名称 * @param definition 工具完整定义元数据 */ public void register(String toolName, ToolDefinition definition) { toolMap.put(toolName, definition); } /** * 根据工具名称获取工具定义 * @param toolName 工具名称 * @return 存在返回工具定义,不存在返回null */ public ToolDefinition getTool(String toolName) { return toolMap.get(toolName); } }
HashMap { "weather" : ToolDefinition }

Schema生成

SpringAI自动扫描

String query(String city)
{ name:"query", parameters:{ city:String } }

发送给大模型。

LLM推理

用户

Prompt

Tools

Qwen

ToolCall

{

"name":"query",

"city":"北京"

}

ToolRouter

ToolCallingManager

内部逻辑

if(toolCall){

findTool()


execute()


injectResult()

}

重点研究方向
研究方向研究问题代表技术
Tool Selection选哪个工具ReAct
Tool Routing多工具调度Router
Tool Planning工具组合Plan&Execute
Tool Learning自动发现工具Toolformer
Tool Reflection工具失败修正Reflexion
Tool Memory工具经验记忆Memory Agent

为什么Tool Calling是Agent的地基

因为后面的所有Agent,本质上都是在Tool Calling上增加能力。

Agent本质
Tool Agent单工具调用
Workflow AgentTool Calling+DAG
Planning AgentTool Calling+任务拆分
Memory AgentTool Calling+向量记忆
Reflection AgentTool Calling+自我评审
Agentic RAGTool Calling+Retriever
Multi-AgentTool Calling+Agent Router
MCP AgentTool Calling+标准协议
Computer AgentTool Calling+GUI Tool
Code AgentTool Calling+IDE Tool

Agent ≈ LLM(大脑) + Tool Calling(手脚) + Memory(记忆) + Planning(前额叶) + Reflection(自我监督)

Workflow Agent

而DAG Workflow解决的是:

大模型如何像项目经理一样组织多个工具协同工作。 (因为LLM天然没有流程控制。需要一个来进程合理的顺序调度的工具

帮我分析特斯拉最近一个月股票走势,并结合最近新闻给出投资建议。

①股票数据

②新闻检索

③新闻总结

④技术分析

⑤风险评估

⑥生成报告

Tool Calling开始失控。

因为LLM天然没有流程控制。

LLM擅长:

推理

不擅长:

调度

DAG

DAG

Directed Acyclic Graph

有向无环图

用户问题

Planner


生成DAG


Executor


结果

允许并行。

A
/ \
/ \
B C
\ /
\ /
D

Planner(任务规划层)
↓ 输出编排拓扑
TaskGraph(任务依赖拓扑载体)
↓ 传入执行引擎
Executor(任务调度执行层)
↓ 聚合全部输出
Result(统一执行结果封装)

职责分离。

DAG四个核心组件

① Node

节点

就是任务。

例如

Node1
查股票
Node2
查新闻
Node3
分析新闻
Node4
生成报告

class Node{ String id; String name; Tool tool; }

② Edge

依赖关系

Node1


Node3

意思

Node3等待Node1。

class Edge{ from; to; }

③ State

WAITING ↓ READY ↓ RUNNING ↓ SUCCESS ↓ FAILED

④ Executor

遍历DAG


判断依赖


调Tool


更新State

Planner为什么存在

这是Agent研究热点。

没有Planner。

用户

分析特斯拉

Executor不知道干什么。

{

tasks:[


"查股票",


"查新闻",


"分析风险",


"输出报告"

]

}

生成

DAG

股票


风险



新闻


报告

Executor干什么

Executor相当于CPU。 类似Java线程池。

SpringBoot怎么设计

TaskGraph

TaskNode

PlannerService

DagExecutor

WorkflowContext

WorkflowContext

所有节点共享数据。


类似

Spring IOC。

Map<String,Object>

股票工具

context.put(

"stock"

,data
);

新闻工具

context.put( "news" ,data );
LangGraph

DAG + State Machine

Workflow(DAG)就是 Agent 的神经系统和调度中心。

问题Tool CallingWorkflow Agent
单工具调用
多步骤任务×
工具依赖×
并行执行×
失败重试×
中断恢复×
状态管理×
长任务执行×

需要自己做“编排层”,Spring AI / 阿里百炼(DashScope)只提供“单步模型能力 + 工具调用能力”,不直接提供完整 Workflow Agent 框架。

Java生态目前不如 Python:

  • LangGraph(Python)
  • AutoGen(Python)
  • CrewAI(Python)

自己实现 Workflow Engine + LLM

Planning Agent

Planning Agent(任务规划代理)本质是:

将“复杂目标”拆解成可执行的结构化子任务(Task List / DAG),再交给执行模块逐步完成。

核心目标不是“回答问题”,而是:

  • 把问题变成步骤
  • 把步骤变成可执行计划
  • 把计划变成执行流程(Execute)
1. ReAct(Reason + Act)

思考 + 行动交替进行

Thought → Action → Observation → Thought → Action ...

作用:

  • 一边规划一边调用工具
  • 适合“动态任务”

用户:分析一个电商系统

Thought:需要了解系统结构
Action:搜索/读取资料
Observation:得到信息
Thought:开始设计模块

需要专业的网站建设服务?

联系我们获取免费的网站建设咨询和方案报价,让我们帮助您实现业务目标

立即咨询