Skip to content

Commit 41a5402

Browse files
committed
direct tool call - clear interrupt
1 parent 32db1e6 commit 41a5402

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/strands/agent/agent.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ def caller(
167167
async def acall() -> ToolResult:
168168
async for event in ToolExecutor._stream(self._agent, tool_use, tool_results, invocation_state):
169169
if isinstance(event, ToolInterruptEvent):
170+
self._agent._interrupt_state.deactivate()
170171
raise RuntimeError("cannot raise interrupt in direct tool call")
171172

172173
return tool_results[0]

tests/strands/agent/test_agent.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2065,6 +2065,14 @@ def test_tool(tool_context):
20652065
with pytest.raises(RuntimeError, match=exp_message):
20662066
agent.tool.test_tool(agent=agent)
20672067

2068+
tru_state = agent._interrupt_state.to_dict()
2069+
exp_state = {
2070+
"activated": False,
2071+
"context": {},
2072+
"interrupts": {},
2073+
}
2074+
assert tru_state == exp_state
2075+
20682076

20692077
def test_agent_tool_caller_interrupt_activated():
20702078
agent = Agent()

0 commit comments

Comments
 (0)