趋近智
虽然有效管理代理的记忆有助于其回忆信息,但在漫长或复杂的交互中,一个相关的问题是确保代理坚定地专注于其主要目标。如果缺乏具体指导,代理可能会偏离其主要目的,特别是在处理新的数据流或处理多个子任务时。本节详细说明了提示工程技术如何帮助代理在长时间操作中维持任务重心,确保它们持续地朝着预期的结果努力。
代理,特别是那些基于大型语言模型构建的,按顺序处理信息。在长时间对话或多步骤任务中,最初的指令或总体目标可能会被“挤出”即时上下文窗口,或者被更新的信息稀释。这可能导致以下几个问题:
有效的记忆管理,如本章前面讨论的,为保留信息提供了根基。维持任务重心在此基础上,通过使用提示主动引导代理的注意力,使其专注于最相关的信息和最终目标,特别是在交互跨越多个回合或涉及动态输入时。
代理在有无重心维持提示下的路径。偏离(左侧)可能发生在支线任务模糊主目标时。维持重心(右侧)涉及在提示中定期强化目标。
为对抗偏离并使代理与其目标保持一致,您可以采用几种提示工程策略:
最直接的方法之一是持续提醒代理其总体目标。这可以通过以下几种方式实现:
System: You are a research assistant. Your primary mission is to compile a detailed report on renewable energy trends. All tasks should contribute to this mission.
User: ... (previous interaction summary) ...
Based on the new data on solar panel efficiency, update the relevant section.
REMEMBER: The overall goal is the comprehensive report on renewable energy trends.
将此类提醒放在提示的开头或结尾可能很有效,因为大型语言模型通常会更重视这些位置的信息。通过提供清晰的任务结构及其在结构中的当前位置,帮助代理维持重心。
User: Goal: Plan a 3-day business trip to Tokyo.
Status:
[X] Day 1: Flights and Hotel Booked.
[ ] Day 2: Meeting Schedule (Current Focus)
- Confirm meeting with ABC Corp.
- Schedule dinner with XYZ Ltd.
[ ] Day 3: Return Travel Arrangements.
Please help draft an email to ABC Corp to confirm the meeting time for Day 2.
这使得更广泛的上下文保持可见,同时专注于即时子任务。您可以明确指示代理优先处理主要任务,并对照此目标自行评估其行动。
User: Before generating a response or taking an action, briefly verify that it directly supports the primary objective of [main objective stated here]. If it seems to deviate, state your reasoning for the deviation or ask for clarification.
User: If you find the current line of inquiry is not contributing to [main goal], please state "Recalibrating focus to [main goal]" and suggest a more relevant next step.
虽然摘要技术(在“提示的信息浓缩技术”中讨论)对于管理上下文窗口限制很有用,但它们也可以根据需要进行调整以维持重心。指示代理创建明确与主要目标关联的摘要。
User: Summarize our conversation so far, highlighting how each completed step has moved us closer to achieving the final goal of [final goal stated here].
这不仅浓缩了信息,还强化了过去行动与总体目标之间的关联。代理通常需要执行子任务,例如使用工具或执行特定信息查询。提示应确保顺利返回主任务。
User: First, use the search tool to find the current population of City X.
After you have the population figure, return to the main task of comparing City X with City Y for urban development planning.
Your next step after getting the population should be to analyze its impact on infrastructure needs for City X.
这为代理创建了一个清晰的“堆栈”:执行子任务,然后返回主流程。当代理处理持续更新的信息时,维持对稳定、长期目标的重心尤其重要。提示需要引导代理整合新数据,而不会被其完全干扰。
User: Current Objective: Optimize the supply chain for Product Z based on cost and delivery time.
New Information Stream: Received an alert about a potential delay at Port A.
Task: Analyze this alert. How does it impact the current objective? Propose adjustments to the supply chain plan specifically to mitigate this new risk while still aiming for optimal cost and delivery time for Product Z.
此提示指导代理从现有主要目标的视角处理新信息。找到这些重心维持提示的正确措辞和频率通常需要反复试验。一种任务类型或代理架构效果好的方法可能需要为另一种进行调整。在较长时间的交互中监控代理的行为:
通过深思熟虑地设计您的提示,使其包含这些重心维持机制,您可以大幅度提升代理在长时间交互中可靠且连贯地执行任务的能力,确保其努力与您的预期目的保持一致。这一点尤其重要,因为代理系统被赋予越来越复杂和长期运行的操作任务。
简洁的语法。内置调试功能。从第一天起就可投入生产。
为 ApX 背后的 AI 系统而构建
这部分内容有帮助吗?
© 2026 ApX Machine Learning用心打造