Interrupt-Aware Run Lifecycle Proposal
Summary
Problem Statement
Agents often need to pause execution to request human approval, gather additional input, or confirm potentially risky actions. Currently, there’s no standardized way to handle these interruptions across different agent frameworks.Motivation
Support human-in-the-loop pauses (and related mechanisms) natively in AG-UI and CopilotKit. This enables compatibility with various framework interrupts, workflow suspend/resume, and other framework-specific pause mechanisms.Status
- Status: Draft
- Author(s): Markus Ecker (mail@mme.xyz)
Overview
This proposal introduces a standardized interrupt/resume pattern:Detailed Specification
Updates to RUN_FINISHED Event
outcome == "interrupt"
, the agent indicates that on
the next run, a value needs to be provided to continue.
Updates to RunAgentInput
Contract Rules
- Resume requests must use the same
threadId
- When given in the
interrupt
, theinterruptId
must be provided viaRunAgentInput
- Agents should handle missing or invalid resume payloads gracefully
Implementation Examples
Minimal Interrupt/Resume
Agent sends interrupt:Complex Approval Flow
Agent requests approval with context:Use Cases
Human Approval
Agents pause before executing sensitive operations (sending emails, making purchases, deleting data).Information Gathering
Agent requests additional context or files from the user mid-execution.Policy Enforcement
Automatic pauses triggered by organizational policies or compliance requirements.Multi-Step Wizards
Complex workflows where each step requires user confirmation or input.Error Recovery
Agent pauses when encountering an error, allowing user to provide guidance.Implementation Considerations
Client SDK Changes
TypeScript SDK:- Extended
RunFinishedEvent
type with outcome and interrupt fields - Updated
RunAgentInput
with resume field - Helper methods for interrupt handling
- Extended
RunFinishedEvent
class - Updated
RunAgentInput
with resume support - Interrupt state management utilities
Framework Integration
Planning Frameworks:- Map framework interrupts to AG-UI interrupt events
- Handle resume payloads in execution continuation
- Convert workflow suspensions to AG-UI interrupts
- Resume workflow execution with provided payload
- Provide interrupt/resume adapter interface
- Documentation for integration patterns
UI Considerations
- Standard components for common interrupt reasons
- Customizable interrupt UI based on payload
- Clear indication of pending interrupts
- History of interrupt/resume actions
Testing Strategy
- Unit tests for interrupt/resume serialization
- Integration tests with multiple frameworks
- E2E tests demonstrating various interrupt scenarios
- State consistency tests across interrupt boundaries
- Performance tests for rapid interrupt/resume cycles