Repository navigation
[Bug] 更新到v3.5.4出现2 validation errors for Tool问题,无法正常使用 #1354
Copy link
Copy link
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
发生了什么
用户输入任何请求都出现astrbot请求失败,错误类型: ValidationError
错误信息: 2 validation errors for Tool
如何复现?
- 启用 gemini服务提供商 “gm_native_search”和 “gm_native_coderunner”
- 调试prompt_prefix, 尝试通过提示词调用
/google_search_tool和 mcp工具fetch - Bot日志无法查看到native_search相关信息和MCP工具调用内容,并且BOT输出内容质量很差
- 关闭 gemini服务提供商里的对应选项
- astrbot无法正常使用
AstrBot 版本、部署方式(如 Windows Docker Desktop 部署)、使用的提供商、使用的消息平台适配器
v3.5.4 docker
操作系统
Linux
报错日志
[21:49:01] [Core] [DBUG] [webchat.webchat_adapter:93]: WebChatAdapter: [Plain(type='Plain', text='/你好', convert=True)]
[21:49:01] [Core] [INFO] [core.event_bus:50]: [webchat] admin/admin: /你好
[21:49:01] [Core] [DBUG] [method.star_request:50]: plugin -> session_controller - handle_session_control_agent
[21:49:01] [Core] [DBUG] [method.star_request:50]: plugin -> session_controller - handle_empty_mention
[21:49:01] [Core] [DBUG] [method.star_request:50]: plugin -> meme_manager - handle_upload_image
[21:49:01] [Core] [DBUG] [method.star_request:50]: plugin -> astrbot_plugin_ignore_at - ignore_at_all
[21:49:01] [Core] [DBUG] [method.star_request:50]: plugin -> astrbot_plugin_appreview - handle_group_request
[21:49:01] [Core] [DBUG] [method.star_request:50]: plugin -> astrbot-python-interpreter - on_message
[21:49:01] [Core] [DBUG] [method.llm_request:126]: hook(on_llm_request) -> astrbot - decorate_llm_req
[21:49:01] [Core] [DBUG] [method.llm_request:126]: hook(on_llm_request) -> astrbot-python-interpreter - on_llm_req
{"type": "log", "level": "DEBUG", "time": "21:49:01", "data": "\u001b[32m [21:49:01] [Core] [DBUG] [method.llm_request:165]: 提供商请求 Payload: ProviderRequest(prompt=\n[User ID: admin, Nickname: admin]\n本人输入的prompt_prefix。 user input:你好, session_id=webchat:FriendMessage:webchat!admin!49266e6f-5d81-4c8f-b262-e73155192b71, image_urls=[], func_tool=[FuncTool(name=reminder, parameters={'type': 'object', 'properties': {'text': {'type': 'string', 'description': 'Must Required. The content of the reminder.'}, 'datetime_str': {'type': 'string', 'description': \"Required when user's reminder is a single reminder. The datetime string of the reminder, Must format with %Y-%m-%d %H:%M\"}, 'cron_expression': {'type': 'string', 'description': \"Required when user's reminder is a repeated reminder. The cron expression of the reminder.\"}, 'human_readable_cron': {'type': 'string', 'description': 'Optional. The human readable cron expression of the reminder.'}}}, description=Call this function when user is asking for setting a reminder., active=True, origin=local), FuncTool(name=web_search, parameters={'type': 'object', 'properties': {'query': {'type': 'string', 'description': '和用户的问题最相关的搜索关键词,用于在 Google 上搜索。'}}}, description=搜索网络以回答用户的问题。当用户需要搜索网络以获取即时性的信息时调用此工具。, active=True, origin=local), FuncTool(name=fetch_url, parameters={'type': 'object', 'properties': {'url': {'type': 'string', 'description': 'The url of the website to fetch content from'}}}, description=fetch the content of a website with the given web url,
{"type": "log", "level": "ERROR", "time": "21:49:01", "data": "\u001b[31m [21:49:01] [Core] [ERRO] [method.llm_request:243]: Traceback (most recent call last):\n File \"/AstrBot/astrbot/core/pipeline/process_stage/method/llm_request.py\", line 182, in requesting\n final_llm_response = await provider.text_chat(\n File \"/AstrBot/astrbot/core/provider/sources/gemini_source.py\", line 480, in text_chat\n return await self._query(payloads, func_tool)\n File \"/AstrBot/astrbot/core/provider/sources/gemini_source.py\", line 335, in _query\n config = await self._prepare_query_config(\n File \"/AstrBot/astrbot/core/provider/sources/gemini_source.py\", line 160, in _prepare_query_config\n types.Tool(function_declarations=func_desc[\"function_declarations\"])\n File \"/usr/local/lib/python3.10/site-packages/pydantic/main.py\", line 214, in __init__\n validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self)\npydantic_core._pydantic_core.ValidationError: 2 validation errors for Tool\nfunction_declarations.4.parameters.properties.max_length.exclusiveMaximum\n Extra inputs are not permitted [type=extra_forbidden, input_value=1000000, input_type=int]\n For further information visit https://errors.pydantic.dev/2.10/v/extra_forbidden\nfunction_declarations.4.parameters.properties.max_length.exclusiveM
[21:49:01] [Core] [DBUG] [result_decorate.stage:103]: hook(on_decorating_result) -> meme_manager - on_decorating_result
[21:49:01] [Core] [DBUG] [webchat.webchat_event:93]: webchat 忽略: Reply
[21:49:01] [Core] [INFO] [respond.stage:211]: AstrBot -> admin/admin: [引用消息] AstrBot 请求失败。
错误类型: ValidationError
错误信息: 2 validation errors for Tool
function_declarations.4.parameters.properties.max_length.exclusiveMaximum
Extra inputs are not permitted [type=extra_forbidden, input_value=1000000, input_type=int]
For further information visit https://errors.pydantic.dev/2.10/v/extra_forbidden
function_declarations.4.parameters.properties.max_length.exclusiveMinimum
Extra inputs are not permitted [type=extra_forbidden, input_value=0, input_type=int]
For further information visit https://errors.pydantic.dev/2.10/v/extra_forbidden
[21:49:01] [Core] [DBUG] [respond.stage:220]: hook(on_after_message_sent) -> meme_manager - after_message_sent
[21:49:01] [Core] [DBUG] [respond.stage:220]: hook(on_after_message_sent) -> astrbot - after_llm_req
[21:49:01] [Core] [DBUG] [pipeline.scheduler:79]: pipeline 执行完毕。
[21:49:06] [Core] [DBUG] [routes.chat:212]: 用户 admin 断开聊天长连接。
你愿意提交 PR 吗?
- 是的,我愿意提交 PR!
Code of Conduct
- 我已阅读并同意遵守该项目的 行为准则。
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working
Type
Projects
- StatusShow more project fieldsDone
Activity
Raven95676 commentedon Apr 20, 2025
由于Gemini原生工具与函数调用机制不兼容(详见下图中的提示),而MCP本质上基于函数调用,因此无法与原生工具同时使用属正常现象。
根据Gemini官方文档说明,启用原生代码执行器可能会降低模型部分领域的能力,这是模型本身的限制。
Gemini原生工具不参与框架函数调用流程,故无相关信息输出。
关于validation errors for Tool,此问题将在 PR #1357 中被修复。