Skip to content

Conversation

@pgrayy
Copy link
Member

@pgrayy pgrayy commented Jan 14, 2026

Description

Support raising interrupts from BeforeNodeCallEvent hooks in Graph.

Usage

from strands import Agent
from strands.experimental.hooks.multiagent import BeforeNodeCallEvent
from strands.hooks import HookProvider
from strands.interrupt import Interrupt
from strands.multiagent import GraphBuilder
from strands.multiagent.base import Status


class ApprovalHook(HookProvider):
    def register_hooks(self, registry):
        registry.add_callback(BeforeNodeCallEvent, self.approve)

    def approve(self, event):
        if event.node_id == "info_agent":
            return

        response = event.interrupt("my_interrupt", reason=f"{event.node_id} needs approval")
        if response != "APPROVE":
            event.cancel_node = "node rejected"


info_agent = Agent(name="info")
weather_agent = Agent(name="weather", system_prompt="JUST SAY THE WORD CACTUS, NOTHING ELSE")

builder = GraphBuilder()
builder.add_node(info_agent, "info_agent")
builder.add_node(weather_agent, "weather_agent")
builder.add_edge("info_agent", "weather_agent")
builder.set_hook_providers([ApprovalHook()])
graph = builder.build()

multiagent_result = graph("What is the weather?")
while multiagent_result.status == Status.INTERRUPTED:
    responses = []
    for interrupt in multiagent_result.interrupts:
        if interrupt.name == "my_interrupt":
            response = input(f"{interrupt.reason} (y/N): ")
            responses.append(
                {
                    "interruptResponse": {
                         "interruptId": interrupt.id,
                         "response": response,
                    },
                },
             )

    multiagent_result = graph(responses)

print(multiagent_result.results)

Follow Ups

  • Support raising interrupts from Agent nodes.
  • Support raising interrupts from MultiAgentBase nodes.
    • This one may be tricky because unlike Agent nodes, MultiAgentBase nodes can run their own session manager which may conflict with the session manager assigned on the parent graph.

Related Issues

#204

Documentation PR

Will update multi-agents section in follow up.

Type of Change

New feature

Testing

How have you tested the change? Verify that the changes do not break functionality or introduce warnings in consuming repositories: agents-docs, agents-tools, agents-cli

  • I ran hatch run prepare: Wrote new unit tests
  • I ran hatch test tests_integ/interrupts/multiagent: Wrote new integ tests

Checklist

  • I have read the CONTRIBUTING document
  • I have added any necessary tests that prove my fix is effective or my feature works
  • I have updated the documentation accordingly
  • I have added an appropriate example to the documentation to outline the feature, or no new docs are needed
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@codecov
Copy link

codecov bot commented Jan 14, 2026

Codecov Report

❌ Patch coverage is 80.76923% with 10 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/strands/multiagent/graph.py 80.76% 5 Missing and 5 partials ⚠️

📢 Thoughts on this report? Let us know!

@pgrayy pgrayy marked this pull request as ready for review January 14, 2026 16:52
zastrowm
zastrowm previously approved these changes Jan 14, 2026
@pgrayy pgrayy mentioned this pull request Jan 14, 2026
4 tasks
@pgrayy pgrayy merged commit 058c03a into strands-agents:main Jan 15, 2026
12 of 15 checks passed
@pgrayy pgrayy deleted the interrupts-graph-kiro branch January 16, 2026 20:09
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.

3 participants