Skip to content

Conversation

@pgrayy
Copy link
Member

@pgrayy pgrayy commented Jan 20, 2026

Motivation

Users configuring Agent instances with interrupt capabilities (via tool_context.interrupt()) currently cannot use them within Graph execution. When an Agent node raises an interrupt, the Graph throws a NotImplementedError. This PR enables Graph to handle agent node interrupts, following the pattern established in the Swarm implementation.

Resolves: #1526

Public API Changes

No public API changes. Graph now properly handles interrupts from Agent nodes using the existing tool_context.interrupt() API:

from strands import Agent, tool
from strands.multiagent import GraphBuilder
from strands.multiagent.base import Status
from strands.types.tools import ToolContext

@tool(name="weather_tool", context=True)
def weather_tool(tool_context: ToolContext) -> str:
    response = tool_context.interrupt("weather_approval", reason="need location")
    return f"Weather in {response}: sunny"

weather_agent = Agent(name="weather", tools=[weather_tool])

builder = GraphBuilder()
builder.add_node(weather_agent, "weather_agent")
graph = builder.build()

# First invocation - will be interrupted
result = graph("What is the weather?")
assert result.status == Status.INTERRUPTED
assert len(result.interrupts) == 1

# Resume with response
responses = [{"interruptResponse": {"interruptId": result.interrupts[0].id, "response": "Seattle"}}]
result = graph(responses)
assert result.status == Status.COMPLETED

Use Cases

  • Human-in-the-loop workflows: Agent nodes can pause for human approval before proceeding with sensitive operations
  • Interactive data collection: Agents can request additional information from users mid-execution
  • Parallel execution with selective interrupts: When multiple nodes run in parallel, non-interrupted nodes complete normally while interrupted nodes wait for responses

Enables Graph to handle interrupts raised from Agent nodes via
tool_context.interrupt(), following the pattern established in Swarm.

Key changes:
- Updated GraphNode to restore agent state from interrupt context when
  resuming, similar to SwarmNode.reset_executor_state()
- Modified _execute_node() to handle agent interrupts by creating
  NodeResult with INTERRUPTED status instead of raising NotImplementedError
- Updated _activate_interrupt() to store agent state (messages, state,
  interrupt_state) when interrupt is raised from agent node
- When parallel nodes execute and one raises interrupt, other nodes
  complete normally while interrupted node waits for response

Closes #1526
@codecov
Copy link

codecov bot commented Jan 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Graph - Interrupt - From Agent Node

2 participants