- 在 mcp_service 的 get_mcp_tools 加载出口全局设置 tool.handle_tool_error = True - 在 toolkits registry 的 @tool 装饰器中对本地工具默认开启 handle_tool_error = True - 修复因 MCP/本地工具内部执行出错抛出 ToolException 时击穿流服务导致 crash 的 bug - 新增两个单元测试进行完备性验证
19 lines
538 B
Python
19 lines
538 B
Python
from __future__ import annotations
|
|
|
|
from yuxi.agents.toolkits.registry import tool
|
|
|
|
|
|
def test_tool_decorator_sets_handle_tool_error():
|
|
"""测试通过 @tool 装饰器注册的工具是否自动设置了 handle_tool_error 为 True"""
|
|
|
|
@tool(
|
|
category="test",
|
|
display_name="测试工具",
|
|
description="这是一个单元测试工具",
|
|
)
|
|
def my_test_tool(arg: str) -> str:
|
|
return f"hello {arg}"
|
|
|
|
assert my_test_tool.name == "my_test_tool"
|
|
assert my_test_tool.handle_tool_error is True
|