Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ def _format_tool_message(message: ChatMessageContent) -> ToolMessage:
Returns:
The formatted tool message.
"""
if len(message.items) == 0:
raise ValueError("Tool message has no items; expected exactly one FunctionResultContent item.")
Comment on lines +137 to +138
Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

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

Add a unit test covering the new empty-items guard (TOOL ChatMessageContent with items=[]), asserting a ValueError is raised and the message is descriptive. This prevents regressions back to an IndexError and locks in the intended error behavior.

Copilot uses AI. Check for mistakes.

if len(message.items) != 1:
logger.warning(
"Unsupported number of items in Tool message while formatting chat history for Azure AI"
Expand Down
Loading