Merge pull request #5411 from jxxghp/copilot/fix-tool-call-exception-handling

This commit is contained in:
jxxghp
2026-01-24 08:20:51 +08:00
committed by GitHub

View File

@@ -75,8 +75,16 @@ class MoviePilotTool(BaseTool, metaclass=ABCMeta):
await self.send_tool_message(merged_message, title="MoviePilot助手")
logger.debug(f'Executing tool {self.name} with args: {kwargs}')
result = await self.run(**kwargs)
logger.debug(f'Tool {self.name} executed with result: {result}')
# 执行工具,捕获异常确保结果总是被存储到记忆中
try:
result = await self.run(**kwargs)
logger.debug(f'Tool {self.name} executed with result: {result}')
except Exception as e:
# 记录异常详情
error_message = f"工具执行异常 ({type(e).__name__}): {str(e)}"
logger.error(f'Tool {self.name} execution failed: {e}', exc_info=True)
result = error_message
# 记忆工具调用结果
if isinstance(result, str):