Skip to content

feat(agent): add human-in-the-loop interrupt system#586

Open
jsamuel1 wants to merge 1 commit intostrands-agents:mainfrom
jsamuel1:feat/interrupt-system
Open

feat(agent): add human-in-the-loop interrupt system#586
jsamuel1 wants to merge 1 commit intostrands-agents:mainfrom
jsamuel1:feat/interrupt-system

Conversation

@jsamuel1
Copy link
Copy Markdown
Contributor

@jsamuel1 jsamuel1 commented Mar 1, 2026

Description

Port the interrupt system from the Python SDK to TypeScript, enabling human-in-the-loop workflows where hook callbacks can pause agent execution to request human input.

Changes

  • Interrupt class and InterruptException for pausing agent execution
  • BeforeToolCallEvent.interrupt() API for hook-based interrupts
  • BeforeToolCallEvent.cancelTool for tool cancellation without interrupt
  • Agent.resumeFromInterrupt() for resuming after human response
  • InterruptEvent stream event emitted when interrupts pause the loop
  • AgentResult.interrupts and stopReason: 'interrupt' support
  • _InterruptState for tracking active interrupts and resume flow
  • Deferred tool execution on resume (skip model, re-execute pending tools)

Testing

  • 14 unit tests for interrupt primitives
  • 5 agent interrupt integration tests (interrupt, resume, cancel, stream events)
  • All 1096 existing tests pass

@jsamuel1 jsamuel1 force-pushed the feat/interrupt-system branch from 61c4af7 to c8212dd Compare March 3, 2026 07:19
@jsamuel1 jsamuel1 marked this pull request as ready for review March 3, 2026 07:25
jsamuel1 added a commit to jsamuel1/sdk-typescript that referenced this pull request Mar 3, 2026
Combines the following feature branches:
- feat/summarizing-conversation-manager (PR strands-agents#524)
- feat/structured-output-integ-tests (PR strands-agents#588)
- feat/interrupt-system (PR strands-agents#586)
- feat/swarm-multi-agent (PR strands-agents#587)
- feat/graph-multi-agent (PR strands-agents#594)

All 1277 unit tests pass. No type errors.
@jsamuel1 jsamuel1 force-pushed the feat/interrupt-system branch from c8212dd to 09dbc0a Compare March 9, 2026 20:55
@jsamuel1 jsamuel1 force-pushed the feat/interrupt-system branch from 09dbc0a to 106c923 Compare March 9, 2026 20:56
@jsamuel1 jsamuel1 force-pushed the feat/interrupt-system branch from 106c923 to 91a1e0d Compare March 18, 2026 23:25
@jsamuel1 jsamuel1 force-pushed the feat/interrupt-system branch from 28813f2 to 8dfea69 Compare March 22, 2026 07:44
@pgrayy
Copy link
Copy Markdown
Member

pgrayy commented Mar 23, 2026

Thank you for raising this PR but unfortunately we need a bit more time to discuss the design with the team. While the interface will likely remain the same as what we have in Python, we want to see if we can simplify the implementation.

Port the interrupt system from the Python SDK to TypeScript:

- Interrupt class and InterruptException for pausing agent execution
- BeforeToolCallEvent.interrupt() API for hook-based interrupts
- BeforeToolCallEvent.cancelTool for tool cancellation without interrupt
- Agent.resumeFromInterrupt() for resuming after human response
- InterruptEvent stream event emitted when interrupts pause the loop
- AgentResult.interrupts and stopReason 'interrupt' support
- _InterruptState for tracking active interrupts and resume flow
- Deferred tool execution on resume (skip model, re-execute pending tools)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants