Skip to content

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

Open
jsamuel1 wants to merge 2 commits intostrands-agents:mainfrom
jsamuel1:feat/interrupt-system
Open

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

Conversation

@jsamuel1
Copy link
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
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)
- Replace this.hooks with this._hooksRegistry in agent.ts
- Replace AgentData with LocalAgent in InterruptEvent
- Rewrite tests to use Plugin interface instead of HookProvider
- Fix interrupt return path to use correct variables (modelMessage
  instead of modelResult which is out of scope)

---
Prompt: review the tests and fix them
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.

1 participant