[FEATURE] Expand interrupt support to all hook events
Problem Statement
Interrupts are currently only available for tools in one specific hook (AfterToolCallEvent). This limits the ability to implement checkpointing and branching capabilities at other points in the agent lifecycle. We need the ability to interrupt agent execution from any hook event to support advanced durability patterns.
Proposed Solution
Extend the interrupt mechanism to all hook events (e.g., BeforeModelInvocationEvent, AfterModelInvocationEvent, BeforeToolCallEvent, AgentInitializedEvent, etc.). This would allow hook implementations to signal an interrupt at any point in the agent execution flow.
Use Case
We are building a durability plugin that provides checkpointing and branching capabilities for Strands agents. To implement this, we need to be able to pause agent execution at various points—not just after tool calls. For example:
- Checkpoint before a model invocation to preserve state
- Interrupt before a tool call to implement approval workflows
- Branch execution paths based on conditions evaluated at different lifecycle stages
Alternatives Solutions
We have implemented workarounds by manipulating internal state, but this is fragile and not officially supported.
Additional Context
No response
There are some cases where we have gaps, but also some places where interrupts don't make sense (specifically I'm a little concerned about AgentInitialized and MessagedAddedEvent).
These two make sense:
- Checkpoint before a model invocation to preserve state
- Interrupt before a tool call to implement approval workflows
Though my understanding is that both use case are already possible:
- BeforeToolCallEvent is an interruptible event
- BeforeModelCallEvent is not interruptible, but in theory once #1138 is implemented, you would be able to snapshot in BeforeModelCallEvent & resume later by not passing a prompt into the agent invocation.
Does that satisfy those use cases?
Could you expand on how you imagine this one being done?:
- Branch execution paths based on conditions evaluated at different lifecycle stages
And then beyond that, are there additional gaps that you imagine?
In the case of the BeforeModelCallEvent we'd still need a way to dynamically change the agent's prompt/model so I think interrupts are still a viable path for that so we can run experiments directly without a runtime deployment. I'll take a closer look at the snapshot one but surface level i think that solves a different issue though.
Thanks for the detailed request. Closing as a duplicate of #1165, which tracks interrupts for any HookEvent, including BeforeModelCallEvent. Today BeforeToolCallEvent, BeforeToolsEvent, and BeforeNodeCallEvent are interruptible in both SDKs (Python source), and the interrupts guide shows how to raise one from a hook callback. Please add your BeforeModelCallEvent and checkpointing use cases to #1165, or open a new issue if something is still missing.