From: aidotengineer
When deploying AI agents into production, several considerations arise, including the need for human approval during processing steps and the reliability of agents running for long periods in the presence of failures [00:00:08]. Agent continuations offer a new mechanism to address these challenges [00:00:24].
Introducing Agent Continuations
Agent continuations, developed by Snaplogic’s agent creator research group, allow for capturing the full state of complex agents [00:00:47]. This capability supports both arbitrary human-in-the-loop processing and provides a basis for reliable agent continuation through taking snapshots [00:00:56].
The concept of agent continuations is inspired by the programming language theory concept of continuations [00:08:14]. This long-standing concept allows for stopping program execution at any point, bundling its state, and then resuming or continuing execution from that specific point at a later time [00:08:21]. It enables taking a snapshot of the program’s execution for later resumption [00:08:49].
Challenges in Agent Execution
Several general challenges are faced with agents today:
- Human-in-the-Loop Humans need to be comfortable with agent automation, requiring human oversight for key aspects of agent execution [00:01:18]. This is crucial for high-value or high-risk tasks, such as transferring large sums of money or deleting accounts, where a human needs to provide final determination [00:01:44].
- Long-running Agents Many agents are designed to be long-running, involving numerous steps in their processing [00:02:12]. The longer a process runs, the higher the chance of failure, necessitating a way to checkpoint agent state to resume without losing all prior work [00:02:19].
- Distributed Environments Agents are increasingly operating in distributed environments, not just on a desktop [00:02:40].
- Multi-Level Agents Sophisticated agents often feature a main orchestrator agent with several sub-agents, which can further have their own sub-agents [00:06:00]. This hierarchical structure complicates handling human approval and state saving [00:06:30].
- Agent Loop Persistence Traditional frameworks often require the agent loop (the code performing the execution) to run continuously, even when waiting for external input like a human response [00:07:23]. This can be inefficient.
Understanding Basic Agent Execution
An agent fundamentally operates as a loop, involving calls to a Large Language Model (LLM) [00:03:01]. The LLM specifies potential tools to use, and if it determines a tool is needed, the agent loop calls that tool, collects the results, and sends them back to the LLM in a progressive cycle [00:03:07]. A tool can even be another agent, creating sub-agent structures [00:03:31].
How Agent Continuations Work
The feasibility of agent continuations stems from how agents interact with LLMs, specifically through the maintenance of a “messages array” [00:10:04]. This array acts as a log of all interactions and is replayed back to the LLM to make its next inference, effectively preserving much of the agent’s state [00:10:09].
Usage in a Framework
When using a framework with continuation support, a tool can be designated as “needing approval” [00:12:37]. Instead of a standard agent class, a “continuation agent class” is used [00:12:50].
If the agent needs to suspend (e.g., for human approval), the response is a “continuation object” instead of a complete agent response [00:13:16]. This object contains metadata explaining the reason for suspension [00:13:26]. The application layer can inspect this object, provide an update (e.g., human approval or disapproval), and send the updated continuation object back to the agent [00:13:54]. The agent then knows to resume execution from the point of suspension [00:14:12].
Implementation Details
When an agent needs to suspend, a continuation object is created [00:15:12]. This object embeds the standard messages array along with additional metadata [00:15:21]. This metadata provides enough information for the continuation to resume when sent back to the agent [00:15:28]. The key insight is that once the continuation object is created, the agent loops can be completely shut down, as all necessary information has been captured to restart everything [00:16:54].
The continuation object’s structure supports arbitrary layers of nesting, enabling it to handle multi-level agents where sub-agents might also suspend [00:18:20]. For example, a resume request
within a continuation object can contain its own nested continuation object for a sub-agent [00:18:34].
Example: Multi-Level HR Agent
Consider a multi-level HR agent with an email tool and an account agent tool (a sub-agent) [00:18:50]. The account agent itself has create account
and authorize account
tools, with authorize account
requiring human approval [00:19:17].
When the HR agent processes a request to create a new account, the sub-agent (account agent) might eventually need human approval for the authorize account
tool [00:19:52]. At this point, the agent will suspend, create a continuation object, and return it to the application layer for processing [00:20:01]. The continuation object propagates back through each level, expanding until the full object reaches the application to inspect and act on [00:21:03]. Once the application updates the object (e.g., with approval), it’s sent back to the HR agent, and the framework restores the agent’s state (including sub-agent state) to resume execution [00:21:20].
Prototype and Future Directions
The prototype implementation is built on the OpenAI Python API with no other dependencies [00:24:12]. The work is being extended beyond human approval to include more general agent suspension points, such as after a certain time, number of turns, or asynchronous requests [00:24:27]. The aim is not to create a new agent framework, but to extend existing ones like Strands or Pyantic AI [00:24:50].
While other frameworks offer forms of state management, this approach is considered novel because it combines a human approval mechanism with the ability to handle arbitrary depths of nesting in complex agents [00:25:03]. This work emerged from the Agent Creator team at Snaplogic, Snaplogic’s visual agent building interface and platform [00:25:48].
In conclusion, agent continuations provide a new mechanism for managing agent state and facilitating human-in-the-loop processing [00:26:34].