Skip to content

Conversation

@pgrayy
Copy link
Member

@pgrayy pgrayy commented Jan 21, 2026

Description

For single-agents, if a tool is interrupted, we do not emit the AfterToolCallEvent (src). There are a few motivations for this behavior:

  • AfterToolCallEvent expects a tool result which we won't have until after the tool finishes executing.
  • By its name, AfterToolCallEvent should happen after the tool is called, which is not the case if we are in the middle of processing an interrupt.

For multi-agents, we always emit an AfterNodeCallEvent even if the node is interrupted. In this PR, we fix the behavior to match AfterToolCallEvent. We will not emit an AfterNodeCallEvent if the node is in the middle of an interrupt.

Related Issues

#1538

Documentation PR

N/A

Type of Change

Bug fix

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: Relying on existing 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.

await self.hooks.invoke_callbacks_async(
AfterNodeCallEvent(self, current_node.node_id, invocation_state)
)
if self.state.completion_status != Status.INTERRUPTED:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note, unlike graph, swarm nodes do not have a status field. Consequently, we need to check the state status.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity, should it?

Would we do it differently for TypeScript?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I definitely think there should be more consistency between GraphNode and SwarmNode and that is something I am planning for in TypeScript. I have to dig a bit deeper but it could be that we are able to utilize one shared node class.

@pgrayy pgrayy marked this pull request as ready for review January 21, 2026 22:59
@codecov
Copy link

codecov bot commented Jan 21, 2026

Codecov Report

❌ Patch coverage is 75.00000% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/strands/multiagent/swarm.py 50.00% 0 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@github-actions github-actions bot added size/s and removed size/xs labels Jan 21, 2026
@pgrayy pgrayy deployed to auto-approve January 21, 2026 23:12 — with GitHub Actions Active
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.

2 participants