Skip to content

Commit 003f8e3

Browse files
committed
Update ToolStreamEvent api to use nested structure
Per PR feedback
1 parent b9be087 commit 003f8e3

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

src/strands/types/_events.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,12 +282,12 @@ def __init__(self, tool_use: ToolUse, tool_stream_data: Any) -> None:
282282
tool_use: The tool invocation producing the stream
283283
tool_stream_data: The yielded event from the tool execution
284284
"""
285-
super().__init__({"tool_stream_tool_use": tool_use, "tool_stream_data": tool_stream_data})
285+
super().__init__({"tool_stream_event": {"tool_use": tool_use, "data": tool_stream_data}})
286286

287287
@property
288288
def tool_use_id(self) -> str:
289289
"""The toolUseId associated with this stream."""
290-
return cast(str, cast(ToolUse, self.get("tool_stream_tool_use")).get("toolUseId"))
290+
return cast(str, cast(ToolUse, self.get("tool_stream_event").get("tool_use")).get("toolUseId"))
291291

292292

293293
class ModelMessageEvent(TypedEvent):

tests/strands/agent/hooks/test_agent_events.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -261,12 +261,16 @@ async def test_stream_e2e_success(alist):
261261
}
262262
},
263263
{
264-
"tool_stream_data": {"tool_streaming": True},
265-
"tool_stream_tool_use": {"input": {}, "name": "streaming_tool", "toolUseId": "12345"},
264+
"tool_stream_event": {
265+
"data": {"tool_streaming": True},
266+
"tool_use": {"input": {}, "name": "streaming_tool", "toolUseId": "12345"},
267+
}
266268
},
267269
{
268-
"tool_stream_data": "Final result",
269-
"tool_stream_tool_use": {"input": {}, "name": "streaming_tool", "toolUseId": "12345"},
270+
"tool_stream_event": {
271+
"data": "Final result",
272+
"tool_use": {"input": {}, "name": "streaming_tool", "toolUseId": "12345"},
273+
}
270274
},
271275
{
272276
"message": {

0 commit comments

Comments
 (0)