有效的长时间运行代理的工具
As AI agents become more capable, developers are increasingly asking them to take on complex tasks requiring work that spans hours, or even days. However, getting agents to make consistent progress across multiple context windows remains an open problem.
随着AI代理变得越来越强大,开发人员越来越多地要求它们承担需要数小时甚至数天的复杂任务。然而,让代理在多个上下文窗口中保持一致的进展仍然是一个未解决的问题。
The core challenge of long-running agents is that they must work in discrete sessions, and each new session begins with no memory of what came before. Imagine a software project staffed by engineers working in shifts, where each new engineer arrives with no memory of what happened on the previous shift. Because context windows are limited, and because most complex projects cannot be completed within a single window, agents need a way to bridge the gap between coding sessions.
长期运行代理的核心挑战在于它们必须在离散的会话中工作,每个新会话开始时对之前的内容没有记忆。想象一个由工程师轮班工作的软件项目,每个新工程师到来时对上一个班次发生的事情没有记忆。由于上下文窗口有限,并且大多数复杂项目无法在单个窗口内完成,代理需要一种方法来弥补编码会话之间的差距。
We developed a two-fold solution to enable the Claude Agent SDK to work effectively across many context windows: an initializer agent that sets up the environment on the first run, and a coding agent that is tasked with making incremental progress in every session, while leaving clear artifacts for the next session. You can find code examples in the accompanying quickstart.
我们开发了一个双重解决方案,以使Claude Agent SDK能够在多个上下文窗口中有效工作:一个初始化代理,在第一次运行时设置环境,以及一个编码代理,负责在每个会话中进行增量进展,同时为下一个会话留下清晰的文档。您可以在随附的快速入门中找到代码示例。
The long-running agent problem
长期运行代理问题
The Claude Agent SDK is a powerful, general-purpose agent harness adept at coding, as well as other tasks that require the model to use tools to gather context, plan, and execute. It has context management capabilities such as compaction, which enables an agent to work on a task without exhausting the context window. Theoretically, given this setup, it should be possible for an agent to continue to do useful work for an arbitrarily long time.
Claude Agent SDK是一个强大的通用代理工具,擅长编码以及其他需要模型使用工具来收集上下文、规划和执行的任务。它具有上下文管理能力,例如压缩,使代理能够在不耗尽上下文窗口的情况下进行任务。理论...