来源:互联网 更新时间:2026-08-23 14:04
大型语言模型(LLM)的推理能力确实厉害,能读输入、做分析、输出文本、代码甚至媒体内容——这点大家都不陌生。但要说它像人类一样能规划、会思考、能调用工具跟物理世界互动,还自带记忆系统?抱歉,目前还真做不到。

举个例子:公司里同事A想知道自己还剩多少年假。单靠LLM,它没法给出答案——因为它根本连企业内部系统都碰不到。可要是能让LLM识别出“查询剩余年假”这个意图,从中抽取出同事A的信息,再调用业务系统的接口把数据拉回来,那就非常实用了。这,就是“Agent”的核心思路。
说得直白点,Agent是一种把LLM的推理能力和外部工具调用能力搭在一起的应用形态,专门用来搞定那些相对复杂的任务。
打个比方:Agent接到一个任务,它拿LLM当“大脑”或“思考引擎”,靠这个大脑决定每一步该怎么走。你可以把Agent想象成一位有战略眼光的指挥官——它不仅清楚战场上每个单元的能力,还能高效地协调它们去完成更复杂的作战目标。
如果你的业务场景满足下面两个条件,采用Agent架构会非常合适:
Agent的根基是LLM的推理能力。它先由LLM做出规划(Planning),然后动用工具去执行(Action),再观察执行结果(Observation)——这个闭环反复运行,直到任务落地。
目前主流的Agent对话实现框架叫ReAct,是普林斯顿大学和Google在2022年提出的提示词方法。它最巧妙的地方在于把“思考”和“行动”融合到了一起。框架的演变历史可以参考下图:
2023年又推出了一个新框架——自我反思(Reflexion),在ReAct的基础上增加了反思环节。具体细节看下图:
下面放一个ReAct论文里用到的例子:
ReAct的提示词长这样:
Answer the following questions as best you can. If it is in order, you can use some tools appropriately. You ha ve access to the following tools:
{tools}
Use the following format:
Question: the input question you must answer1
Thought: you should always think about what to do and what tools to use.
Action: the action to take, should be one of {toool_names}
Action Input: the input to the action
Observation: the result of the action
... (this Thought/Action/Action Input/Observation can be repeated zero or more times)
Thought: I now know the final answer
Final Answer: the final answer to the original input question
Begin!
history: {history}
Question: {input}
Thought: {agent_scratchpad}
其中agent_scratchpad是Agent的思维记录,代表中间action和observation的过程,会被格式化成 """Observation: {observation}Thought:{action}""" 这样。
假设我们手头有:
google-search(用谷歌搜索网络信息)和 llm-calc(用大模型+Python做数学运算)。那么第一轮对话的输入是:
Answer the following questions as best you can. If it is in order, you can use some tools appropriately. You ha ve access to the following tools:
google-search: 用谷歌Search搜索网络开源信息的工具
llm-calc: 用大模型和Python做数学运算的工具
Use the following format:
Question: the input question you must answer
Thought: you should always think about what to do and what tools to use.
Action: the action to take, should be one of [google-search, llm-calc]
Action Input: the input to the action
Observation: the result of the action
... (this Thought/Action/Action Input/Observation can be repeated zero or more times)
Thought: I now know the final answer
Final Answer: the final answer to the original input question
Begin!
history:
Question: 目前的黄金价格是多少?如果我想在这个价格上加价20%,我应该怎么定价?
Thought:
模型输出后解析,拿到Thought、Action和Action Input:
Thought: 我应该使用搜索工具来查找黄金的当前市场价格。
Action: google-search
Action Input: 黄金当前价格
调用google-search工具,输入“黄金当前价格”,拿到返回结果Observation:“根据网络资料显示,每克黄金的价格为60美元。” 然后把上面这些内容整理好,塞回ReAct提示词模板,开启第二轮对话的输入:
Answer the following questions as best you can. If it is in order, you can use some tools appropriately. You ha ve access to the following tools:
google-search: 用谷歌Search搜索网络开源信息的工具
llm-calc: 用大模型和Python做数学运算的工具
Use the following format:
Question: the input question you must answer
Thought: you should always think about what to do and what tools to use.
Action: the action to take, should be one of [google-search, llm-calc]
Action Input: the input to the action
Observation: the result of the action
... (this Thought/Action/Action Input/Observation can be repeated zero or more times)
Thought: I now know the final answer
Final Answer: the final answer to the original input question
Begin!
history:
Question: 目前的黄金价格是多少?如果我想在这个价格上加价20%,我应该怎么定价?
Thought: 我应该使用搜索工具来查找答案,这样我可以快速地找到所需的信息。
Action: google-search
Action Input: 黄金当前价格
Observation: 根据网络资料显示,每克黄金的价格为60美元。
Thought:
再次解析输出:
Thought: 我需要计算在这个价格基础上加价20%的新价格是多少。
Action: llm-calc
Action Input: 60*1.20
调用llm-calc工具,输入60*1.20,拿到Observation:“72”。然后继续整理,启动第三轮对话:
Answer the following questions as best you can. If it is in order, you can use some tools appropriately. You ha ve access to the following tools:
google-search: 用谷歌Search搜索网络开源信息的工具
llm-calc: 用大模型和Python做数学运算的工具
Use the following format:
Question: the input question you must answer
Thought: you should always think about what to do and what tools to use.
Action: the action to take, should be one of [google-search, llm-calc]
Action Input: the input to the action
Observation: the result of the action
... (this Thought/Action/Action Input/Observation can be repeated zero or more times)
Thought: I now know the final answer
Final Answer: the final answer to the original input question
Begin!
history:
Question: 目前的黄金价格是多少?如果我想在这个价格上加价20%,我应该怎么定价?
Thought: 我应该使用搜索工具来查找答案,这样我可以快速地找到所需的信息。
Action: google-search
Action Input: 黄金当前价格
Observation: 根据网络资料显示,每克黄金的价格为60美元。
Thought: 我需要计算在这个价格基础上加价20%的新价格是多少。
Action: llm-calc
Action Input: 60*1.20
Observation: 72
Thought:
第三次解析输出:
Thought: 我知道最终答案了。
Final Answer: 如果想在当前价格上加价20%卖出黄金,应该定价为每克72美元。 腾讯ima怎么把微信内容一键导入知识库?
黄金价格不断创新高!黄金稳定币XAU、PAXG市值达11亿美元
腾讯ima怎么创建共享知识库?
Celestia价格预测2026-2032:TIA币能否引领山寨币上涨行情?历史价格回顾
新浪互联网热点小时报丨2026年07月26日16时_今日实时互联网热点速递
比特币(BTC)核心周期指标复刻历史走势 价格或跌破5.8万美元关键支撑位
新浪机器学习热点小时报丨2026年07月25日18时_今日实时机器学习热点速递
WorkBuddy微信版怎么获得积分?
新浪人工智能热点小时报丨2026年07月30日18时_今日实时人工智能热点速递
比特币 2025 年价格预测:BTC 的未来走势
车载冰箱重置到出厂设置几步?
5000元起的鼠标哪个最值得入手?
管线机怎么接云米净水器
短剧《史上最强洪荒修为》剧情介绍
Aptos(APT)2026-2032年价格预测与历史走势梳理
笔记本移动电源推荐哪款?
结婚家电首选:Leader懒人三筒Ultra热泵洗烘一体
kimi提示词专家使用方法新手指南
短剧《仙人跳获透视,古玩玉器我全拿捏》剧情介绍
腾讯ima知识库怎么分类管理?
手机号码测吉凶
本站所有软件,都由网友上传,如有侵犯你的版权,请发邮件haolingcc@hotmail.com 联系删除。 版权所有 Copyright@2012-2013 haoling.cc