fix: Ensure safe assignment to tool_blocks_map in agent_message handling (#5239)

fix: ensure tool_blocks_map assignment is safe by checking content availability in agent_message
This commit is contained in:
Gabriel Luiz Freitas Almeida 2024-12-12 17:45:34 -03:00 • committed by GitHub
commit 222f15d8a1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -149,7 +149,8 @@ async def handle_on_tool_start(
agent_message.content_blocks[0].contents.append(tool_content)
agent_message = await send_message_method(message=agent_message)
tool_blocks_map[tool_key] = agent_message.content_blocks[0].contents[-1]
if agent_message.content_blocks and agent_message.content_blocks[0].contents:
tool_blocks_map[tool_key] = agent_message.content_blocks[0].contents[-1]
return agent_message, new_start_time