尧图网站建设 尧图网络
  • 首页
  • 关于我们
  • 服务项目
  • 案例展示
  • 建站流程
  • 资讯中心
  • 联系我们
首页/资讯中心/详情

Plan-and-Execute Agents

Plan-and-Execute Agents
📅 发布时间:2026/6/17 23:17:09

Plan-and-Execute Agents

https://blog.langchain.com/planning-agents/

Over the past year, language model-powered agents and state machines have emerged as a promising design pattern for creating flexible and effective ai-powered products.

At their core, agents use LLMs as general-purpose problem-solvers, connecting them with external resources to answer questions or accomplish tasks.

LLM agents typically have the following main steps:

  1. Propose action: the LLM generates text to respond directly to a user or to pass to a function.
  2. Execute action: your code invokes other software to do things like query a database or call an API.
  3. Observe: react to the response of the tool call by either calling another function or responding to the user.

The ReAct agent is a great prototypical design for this, as it prompts the language model using a repeated thought, act, observation loop:

Thought: I should call Search() to see the current score of the game.
Act: Search("What is the current score of game X?")
Observation: The current score is 24-21
... (repeat N times)

A typical ReAct-style agent trajectory.

This takes advantage of Chain-of-thought prompting to make a single action choice per step. While this can be effect for simple tasks, it has a couple main downsides:

  1. It requires an LLM call for each tool invocation.
  2. The LLM only plans for 1 sub-problem at a time. This may lead to sub-optimal trajectories, since it isn't forced to "reason" about the whole task.

One way to overcome these two shortcomings is through an explicit planning step. Below are two such designs we have implemented in LangGraph.

Plan-And-Execute

🔗 Python Link

🔗 JS Link

Plan-and-execute Agent

Based loosely on Wang, et. al.’s paper on Plan-and-Solve Prompting, and Yohei Nakajima’s BabyAGI project, this simple architecture is emblematic of the planning agent architecture. It consists of two basic components:

  1. A planner, which prompts an LLM to generate a multi-step plan to complete a large task.
  2. Executor(s), which accept the user query and a step in the plan and invoke 1 or more tools to complete that task.

Once execution is completed, the agent is called again with a re-planning prompt, letting it decide whether to finish with a response or whether to generate a follow-up plan (if the first plan didn’t have the desired effect).

This agent design lets us avoid having to call the large planner LLM for each tool invocation. It still is restricted by serial tool calling and uses an LLM for each task since it doesn't support variable assignment.

 

REF

https://www.bilibili.com/video/BV1vJ4m1s7Zn?spm_id_from=333.788.videopod.sections&vd_source=57e261300f39bf692de396b55bf8c41b

https://www.bilibili.com/video/BV1qa43z5EBJ/?spm_id_from=333.337.search-card.all.click&vd_source=57e261300f39bf692de396b55bf8c41b

https://github.com/MehdiRezvandehy/Multi-Step-Plan-and-Execute-Agents-with-LangGraph/blob/main/langgraph_plan_execute.ipynb

https://github.com/fanqingsong/langgraph-plan-and-react-agent

https://github.com/fanqingsong/plan-execute-langgraph

 

LANGCHAIN MEMORY

https://www.cnblogs.com/mangod/p/18243321

https://reference.langchain.com/python/langchain_core/prompts/#langchain_core.prompts.chat.ChatPromptTemplate

https://langchain-tutorials.com/lessons/langchain-essentials/lesson-6

from langchain.memory import ConversationBufferMemorymemory = ConversationBufferMemory(return_messages=True)
memory.load_memory_variables({})memory.save_context({"input": "我的名字叫张三"}, {"output": "你好,张三"})
memory.load_memory_variables({})memory.save_context({"input": "我是一名 IT 程序员"}, {"output": "好的,我知道了"})
memory.load_memory_variables({})from langchain.prompts import ChatPromptTemplate
from langchain.prompts import ChatPromptTemplate, MessagesPlaceholderprompt = ChatPromptTemplate.from_messages([("system", "你是一个乐于助人的助手。"),MessagesPlaceholder(variable_name="history"),("human", "{user_input}"),]
)
chain = prompt | modeluser_input = "你知道我的名字吗?"
history = memory.load_memory_variables({})["history"]chain.invoke({"user_input": user_input, "history": history})user_input = "中国最高的山是什么山?"
res = chain.invoke({"user_input": user_input, "history": history})
memory.save_context({"input": user_input}, {"output": res.content})res = chain.invoke({"user_input": "我们聊得最后一个问题是什么?", "history": history})

 

https://docs.langchain.com/oss/python/langchain/messages

 

出处:http://www.cnblogs.com/lightsong/ 本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接。

相关新闻

  • 无问智推:开启数据消费新范式
  • revit esc取消报错处理
  • 2025年定制全屋家居公司权威推荐榜单:全屋定制装修/全屋定制品牌/全屋定制源头公司精选

最新新闻

  • 2026年常州翡翠回收全域白皮书出炉,盘点常州优质门店,首选添价收 - 薛定谔的梨花猫
  • 2026年上海留学中介全测评,录取榜单含金量谁来验证 - 速递信息
  • 152、平台 Camera 启动速度优化:从 Kernel 加载到 HAL 就绪的每阶段耗时拆解
  • 北京买狗避坑攻略,认准实体靠谱犬舍,告别星期狗套路 - 北京同城宠物基地
  • AI Agent落地实战:从任务闭环到可信交付的工程化路径
  • 南京亨得利维修时长预估查询:2026年紫峰大厦官方售后深度实测,从送修到取表全流程时间轴与各品牌服务周期完整解析 - 劳力士官方售后中心

日新闻

  • 2026年不锈钢卷板厂家推荐排行榜:冷轧热轧/304/201不锈钢卷板,高颜值耐腐蚀源头厂家实力精选 - 企业推荐官【官方】
  • FLUX.1-dev FP8模型实战指南:24GB以下显卡高效部署方案
  • 2026佛山长途搬家价目表:跨省跨市搬家费用完整计算指南 - 从来都是英雄出少年

周新闻

  • 3步解锁iOS设备:applera1n激活锁绕过完全指南
  • 39 2026 人工智能证书终极盘点,普通人选 AI 证书可以从这些方向入手
  • Redis 暴露公网有多危险?从端口检查到补救步骤

月新闻

  • 【总结】入门篇:50句话让你记住架构核心概念
  • WeChatMsg技术方案解析:实现Mac微信数据自主管理的完整解决方案
  • WeChatMsg:革新性微信数据备份方案,打造你的专属数字记忆库

关于尧图

  • 公司简介
  • 团队介绍
  • 企业文化
  • 荣誉资质

服务项目

  • 定制开发
  • 电商建站
  • UI 设计
  • 运维服务

快速链接

  • 案例展示
  • 建站流程
  • 常见问题
  • 资讯中心

联系方式

  • 📍北京市朝阳区互联网产业园 A 座 10 层
  • 📞400-888-8888
  • ✉️contact@rkmt.cn
  • 🕐周一至周日 9:00-21:00

© 2024 北京尧图网络科技有限公司 版权所有 | 京 ICP 备 XXXXXXXX 号