Skip to content

Commit 386734b

Browse files
committed
fix: Check messages array size
1 parent 62f986b commit 386734b

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/strands/event_loop/event_loop.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,13 @@ def _has_tool_use_in_latest_message(messages: "Messages") -> bool:
6565
Returns:
6666
True if the latest message contains at least one ToolUse content block, False otherwise.
6767
"""
68-
latest_message = messages[-1]
69-
content_blocks = latest_message.get("content", [])
68+
if len(messages) > 0:
69+
latest_message = messages[-1]
70+
content_blocks = latest_message.get("content", [])
7071

71-
for content_block in content_blocks:
72-
if "toolUse" in content_block:
73-
return True
72+
for content_block in content_blocks:
73+
if "toolUse" in content_block:
74+
return True
7475

7576
return False
7677

0 commit comments

Comments
 (0)