Skip to content

Commit 9954606

Browse files
authored
fix(mcp): Error message based on text attribute instead of str(part) (#4582)
1 parent 73eb202 commit 9954606

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

  • livekit-agents/livekit/agents/llm

livekit-agents/livekit/agents/llm/mcp.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,10 @@ async def _tool_called(raw_arguments: dict[str, Any]) -> Any:
108108
tool_result = await self._client.call_tool(name, raw_arguments)
109109

110110
if tool_result.isError:
111-
error_str = "\n".join(str(part) for part in tool_result.content)
111+
error_str = "\n".join(
112+
part.text if hasattr(part, "text") else str(part)
113+
for part in tool_result.content
114+
)
112115
raise ToolError(error_str)
113116

114117
# TODO(theomonnom): handle images & binary messages

0 commit comments

Comments
 (0)