Repository navigation
[Bug] [Gemini] 客户端构造请求时的 schema错误,导致LLM调用全部失败 #6029
Copy link
Copy link
Closed
Labels
area:providerThe bug / feature is about AI Provider, Models, LLM Agent, LLM Agent Runner.The bug / feature is about AI Provider, Models, LLM Agent, LLM Agent Runner.bugSomething isn't workingSomething isn't working
Description
What happened / 发生了什么
启用原生代码执行器可以解决这个问题,是升级到新版本之后出现的这个问题。
Gemini 的 Function Calling (函数调用/工具调用) 功能时,向 API 提交的函数声明(Schema)格式不正确,导致gemini所有模型调用失败,provider可用性全部通过。
除了log插件外已禁用全部插件。经测试切换为默认人格也是同样的问题。
Reproduce / 如何复现?
配置文件(已移除敏感信息)
AstrBot version, deployment method (e.g., Windows Docker Desktop deployment), provider used, and messaging platform used. / AstrBot 版本、部署方式(如 Windows Docker Desktop 部署)、使用的提供商、使用的消息平台适配器
Windows Docker Desktop docker compose + napcat
v4.19.5
原生API
OS
Windows
Logs / 报错日志
私聊或者群聊触发词触发LLM报错的关键日志,更多的debug日志可以下载下面的文件
[2026-03-11 15:13:01.863] [Core] [WARN] [v4.19.5] [runners.tool_loop_agent_runner:268]: Chat Model google_gemini/gemini-3-flash-preview request error: 400 INVALID_ARGUMENT. {'error': {'code': 400, 'message': '* GenerateContentRequest.tools[0].function_declarations[9].parameters.properties[source_uuids].items: missing field.\n', 'status': 'INVALID_ARGUMENT'}} Traceback (most recent call last): File "/AstrBot/astrbot/core/agent/runners/tool_loop_agent_runner.py", line 243, in _iter_llm_responses_with_fallback async for resp in self._iter_llm_responses(include_model=idx == 0): File "/AstrBot/astrbot/core/agent/runners/tool_loop_agent_runner.py", line 220, in _iter_llm_responses yield await self.provider.text_chat(**payload) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/AstrBot/astrbot/core/provider/sources/gemini_source.py", line 769, in text_chat if await self._handle_api_error(e, keys): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/AstrBot/astrbot/core/provider/sources/gemini_source.py", line 128, in _handle_api_error raise e File "/AstrBot/astrbot/core/provider/sources/gemini_source.py", line 767, in text_chat return await self._query(payloads, func_tool) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/AstrBot/astrbot/core/provider/sources/gemini_source.py", line 542, in _query result = await self.client.models.generate_content( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/google/genai/models.py", line 7542, in generate_content return await self._generate_content( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/google/genai/models.py", line 6330, in _generate_content response = await self._api_client.async_request( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/google/genai/_api_client.py", line 1447, in async_request result = await self._async_request( ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/google/genai/_api_client.py", line 1380, in _async_request return await self._async_retry( # type: ignore[no-any-return] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/tenacity/asyncio/__init__.py", line 112, in __call__ do = await self.iter(retry_state=retry_state) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/tenacity/asyncio/__init__.py", line 157, in iter result = await action(retry_state) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/tenacity/_utils.py", line 111, in inner return call(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/tenacity/__init__.py", line 413, in exc_check raise retry_exc.reraise() ^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/tenacity/__init__.py", line 184, in reraise raise self.last_attempt.result() ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/concurrent/futures/_base.py", line 449, in result return self.__get_result() ^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/concurrent/futures/_base.py", line 401, in __get_result raise self._exception File "/usr/local/lib/python3.12/site-packages/tenacity/asyncio/__init__.py", line 116, in __call__ result = await fn(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/google/genai/_api_client.py", line 1325, in _async_request_once await errors.APIError.raise_for_async_response(response) File "/usr/local/lib/python3.12/site-packages/google/genai/errors.py", line 216, in raise_for_async_response await cls.raise_error_async(status_code, response_json, response) File "/usr/local/lib/python3.12/site-packages/google/genai/errors.py", line 238, in raise_error_async raise ClientError(status_code, response_json, response) google.genai.errors.ClientError: 400 INVALID_ARGUMENT. {'error': {'code': 400, 'message': '* GenerateContentRequest.tools[0].function_declarations[9].parameters.properties[source_uuids].items: missing field.\n', 'status': 'INVALID_ARGUMENT'}} [2026-03-11 15:13:01.875] [Core] [WARN] [v4.19.5] [runners.tool_loop_agent_runner:235]: Switched from google_gemini/gemini-3-flash-preview to fallback chat provider: google_gemini/gemini-3.1-flash-lite-preview [2026-03-11 15:13:02.024] [Core] [WARN] [v4.19.5] [runners.tool_loop_agent_runner:268]: Chat Model google_gemini/gemini-3.1-flash-lite-preview request error: 400 INVALID_ARGUMENT. {'error': {'code': 400, 'message': '* GenerateContentRequest.tools[0].function_declarations[9].parameters.properties[source_uuids].items: missing field.\n', 'status': 'INVALID_ARGUMENT'}} Traceback (most recent call last): File "/AstrBot/astrbot/core/agent/runners/tool_loop_agent_runner.py", line 243, in _iter_llm_responses_with_fallback async for resp in self._iter_llm_responses(include_model=idx == 0): File "/AstrBot/astrbot/core/agent/runners/tool_loop_agent_runner.py", line 220, in _iter_llm_responses yield await self.provider.text_chat(**payload) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/AstrBot/astrbot/core/provider/sources/gemini_source.py", line 769, in text_chat if await self._handle_api_error(e, keys): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/AstrBot/astrbot/core/provider/sources/gemini_source.py", line 128, in _handle_api_error raise e File "/AstrBot/astrbot/core/provider/sources/gemini_source.py", line 767, in text_chat return await self._query(payloads, func_tool) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/AstrBot/astrbot/core/provider/sources/gemini_source.py", line 542, in _query result = await self.client.models.generate_content( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/google/genai/models.py", line 7542, in generate_content return await self._generate_content( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/google/genai/models.py", line 6330, in _generate_content response = await self._api_client.async_request( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/google/genai/_api_client.py", line 1447, in async_request result = await self._async_request( ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/google/genai/_api_client.py", line 1380, in _async_request return await self._async_retry( # type: ignore[no-any-return] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/tenacity/asyncio/__init__.py", line 112, in __call__ do = await self.iter(retry_state=retry_state) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/tenacity/asyncio/__init__.py", line 157, in iter result = await action(retry_state) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/tenacity/_utils.py", line 111, in inner return call(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/tenacity/__init__.py", line 413, in exc_check raise retry_exc.reraise() ^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/tenacity/__init__.py", line 184, in reraise raise self.last_attempt.result() ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/concurrent/futures/_base.py", line 449, in result return self.__get_result() ^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/concurrent/futures/_base.py", line 401, in __get_result raise self._exception File "/usr/local/lib/python3.12/site-packages/tenacity/asyncio/__init__.py", line 116, in __call__ result = await fn(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/google/genai/_api_client.py", line 1325, in _async_request_once await errors.APIError.raise_for_async_response(response) File "/usr/local/lib/python3.12/site-packages/google/genai/errors.py", line 216, in raise_for_async_response await cls.raise_error_async(status_code, response_json, response) File "/usr/local/lib/python3.12/site-packages/google/genai/errors.py", line 238, in raise_error_async raise ClientError(status_code, response_json, response) google.genai.errors.ClientError: 400 INVALID_ARGUMENT. {'error': {'code': 400, 'message': '* GenerateContentRequest.tools[0].function_declarations[9].parameters.properties[source_uuids].items: missing field.\n', 'status': 'INVALID_ARGUMENT'}} [2026-03-11 15:13:02.036] [Core] [WARN] [v4.19.5] [runners.tool_loop_agent_runner:235]: Switched from google_gemini/gemini-3.1-flash-lite-preview to fallback chat provider: google_gemini/gemini-2.5-flash-lite-preview-09-2025 [2026-03-11 15:13:02.167] [Core] [WARN] [v4.19.5] [runners.tool_loop_agent_runner:268]: Chat Model google_gemini/gemini-2.5-flash-lite-preview-09-2025 request error: 400 INVALID_ARGUMENT. {'error': {'code': 400, 'message': '* GenerateContentRequest.tools[0].function_declarations[9].parameters.properties[source_uuids].items: missing field.\n', 'status': 'INVALID_ARGUMENT'}} Traceback (most recent call last): File "/AstrBot/astrbot/core/agent/runners/tool_loop_agent_runner.py", line 243, in _iter_llm_responses_with_fallback async for resp in self._iter_llm_responses(include_model=idx == 0): File "/AstrBot/astrbot/core/agent/runners/tool_loop_agent_runner.py", line 220, in _iter_llm_responses yield await self.provider.text_chat(**payload) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/AstrBot/astrbot/core/provider/sources/gemini_source.py", line 769, in text_chat if await self._handle_api_error(e, keys): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/AstrBot/astrbot/core/provider/sources/gemini_source.py", line 128, in _handle_api_error raise e File "/AstrBot/astrbot/core/provider/sources/gemini_source.py", line 767, in text_chat return await self._query(payloads, func_tool) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/AstrBot/astrbot/core/provider/sources/gemini_source.py", line 542, in _query result = await self.client.models.generate_content( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/google/genai/models.py", line 7542, in generate_content return await self._generate_content( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/google/genai/models.py", line 6330, in _generate_content response = await self._api_client.async_request( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/google/genai/_api_client.py", line 1447, in async_request result = await self._async_request( ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/google/genai/_api_client.py", line 1380, in _async_request return await self._async_retry( # type: ignore[no-any-return] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/tenacity/asyncio/__init__.py", line 112, in __call__ do = await self.iter(retry_state=retry_state) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/tenacity/asyncio/__init__.py", line 157, in iter result = await action(retry_state) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/tenacity/_utils.py", line 111, in inner return call(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/tenacity/__init__.py", line 413, in exc_check raise retry_exc.reraise() ^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/tenacity/__init__.py", line 184, in reraise raise self.last_attempt.result() ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/concurrent/futures/_base.py", line 449, in result return self.__get_result() ^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/concurrent/futures/_base.py", line 401, in __get_result raise self._exception File "/usr/local/lib/python3.12/site-packages/tenacity/asyncio/__init__.py", line 116, in __call__ result = await fn(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/google/genai/_api_client.py", line 1325, in _async_request_once await errors.APIError.raise_for_async_response(response) File "/usr/local/lib/python3.12/site-packages/google/genai/errors.py", line 216, in raise_for_async_response await cls.raise_error_async(status_code, response_json, response) File "/usr/local/lib/python3.12/site-packages/google/genai/errors.py", line 238, in raise_error_async raise ClientError(status_code, response_json, response) google.genai.errors.ClientError: 400 INVALID_ARGUMENT. {'error': {'code': 400, 'message': '* GenerateContentRequest.tools[0].function_declarations[9].parameters.properties[source_uuids].items: missing field.\n', 'status': 'INVALID_ARGUMENT'}} [2026-03-11 15:13:02.178] [Core] [WARN] [v4.19.5] [runners.tool_loop_agent_runner:235]: Switched from google_gemini/gemini-2.5-flash-lite-preview-09-2025 to fallback chat provider: google_gemini/gemini-3.1-pro-preview [2026-03-11 15:13:02.313] [Core] [WARN] [v4.19.5] [runners.tool_loop_agent_runner:268]: Chat Model google_gemini/gemini-3.1-pro-preview request error: 400 INVALID_ARGUMENT. {'error': {'code': 400, 'message': '* GenerateContentRequest.tools[0].function_declarations[9].parameters.properties[source_uuids].items: missing field.\n', 'status': 'INVALID_ARGUMENT'}} Traceback (most recent call last): File "/AstrBot/astrbot/core/agent/runners/tool_loop_agent_runner.py", line 243, in _iter_llm_responses_with_fallback async for resp in self._iter_llm_responses(include_model=idx == 0): File "/AstrBot/astrbot/core/agent/runners/tool_loop_agent_runner.py", line 220, in _iter_llm_responses yield await self.provider.text_chat(**payload) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/AstrBot/astrbot/core/provider/sources/gemini_source.py", line 769, in text_chat if await self._handle_api_error(e, keys): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/AstrBot/astrbot/core/provider/sources/gemini_source.py", line 128, in _handle_api_error raise e File "/AstrBot/astrbot/core/provider/sources/gemini_source.py", line 767, in text_chat return await self._query(payloads, func_tool) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/AstrBot/astrbot/core/provider/sources/gemini_source.py", line 542, in _query result = await self.client.models.generate_content( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/google/genai/models.py", line 7542, in generate_content return await self._generate_content( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/google/genai/models.py", line 6330, in _generate_content response = await self._api_client.async_request( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/google/genai/_api_client.py", line 1447, in async_request result = await self._async_request( ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/google/genai/_api_client.py", line 1380, in _async_request return await self._async_retry( # type: ignore[no-any-return] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/tenacity/asyncio/__init__.py", line 112, in __call__ do = await self.iter(retry_state=retry_state) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/tenacity/asyncio/__init__.py", line 157, in iter result = await action(retry_state) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/tenacity/_utils.py", line 111, in inner return call(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/tenacity/__init__.py", line 413, in exc_check raise retry_exc.reraise() ^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/tenacity/__init__.py", line 184, in reraise raise self.last_attempt.result() ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/concurrent/futures/_base.py", line 449, in result return self.__get_result() ^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/concurrent/futures/_base.py", line 401, in __get_result raise self._exception File "/usr/local/lib/python3.12/site-packages/tenacity/asyncio/__init__.py", line 116, in __call__ result = await fn(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/google/genai/_api_client.py", line 1325, in _async_request_once await errors.APIError.raise_for_async_response(response) File "/usr/local/lib/python3.12/site-packages/google/genai/errors.py", line 216, in raise_for_async_response await cls.raise_error_async(status_code, response_json, response) File "/usr/local/lib/python3.12/site-packages/google/genai/errors.py", line 238, in raise_error_async raise ClientError(status_code, response_json, response) google.genai.errors.ClientError: 400 INVALID_ARGUMENT. {'error': {'code': 400, 'message': '* GenerateContentRequest.tools[0].function_declarations[9].parameters.properties[source_uuids].items: missing field.\n', 'status': 'INVALID_ARGUMENT'}} [2026-03-11 15:13:02.325] [Core] [WARN] [v4.19.5] [runners.tool_loop_agent_runner:235]: Switched from google_gemini/gemini-3.1-pro-preview to fallback chat provider: google_gemini/gemini-3-pro-preview [2026-03-11 15:13:02.471] [Core] [WARN] [v4.19.5] [runners.tool_loop_agent_runner:268]: Chat Model google_gemini/gemini-3-pro-preview request error: 400 INVALID_ARGUMENT. {'error': {'code': 400, 'message': '* GenerateContentRequest.tools[0].function_declarations[9].parameters.properties[source_uuids].items: missing field.\n', 'status': 'INVALID_ARGUMENT'}} Traceback (most recent call last): File "/AstrBot/astrbot/core/agent/runners/tool_loop_agent_runner.py", line 243, in _iter_llm_responses_with_fallback async for resp in self._iter_llm_responses(include_model=idx == 0): File "/AstrBot/astrbot/core/agent/runners/tool_loop_agent_runner.py", line 220, in _iter_llm_responses yield await self.provider.text_chat(**payload) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/AstrBot/astrbot/core/provider/sources/gemini_source.py", line 769, in text_chat if await self._handle_api_error(e, keys): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/AstrBot/astrbot/core/provider/sources/gemini_source.py", line 128, in _handle_api_error raise e File "/AstrBot/astrbot/core/provider/sources/gemini_source.py", line 767, in text_chat return await self._query(payloads, func_tool) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/AstrBot/astrbot/core/provider/sources/gemini_source.py", line 542, in _query result = await self.client.models.generate_content( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/google/genai/models.py", line 7542, in generate_content return await self._generate_content( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/google/genai/models.py", line 6330, in _generate_content response = await self._api_client.async_request( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/google/genai/_api_client.py", line 1447, in async_request result = await self._async_request( ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/google/genai/_api_client.py", line 1380, in _async_request return await self._async_retry( # type: ignore[no-any-return] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/tenacity/asyncio/__init__.py", line 112, in __call__ do = await self.iter(retry_state=retry_state) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/tenacity/asyncio/__init__.py", line 157, in iter result = await action(retry_state) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/tenacity/_utils.py", line 111, in inner return call(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/tenacity/__init__.py", line 413, in exc_check raise retry_exc.reraise() ^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/tenacity/__init__.py", line 184, in reraise raise self.last_attempt.result() ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/concurrent/futures/_base.py", line 449, in result return self.__get_result() ^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/concurrent/futures/_base.py", line 401, in __get_result raise self._exception File "/usr/local/lib/python3.12/site-packages/tenacity/asyncio/__init__.py", line 116, in __call__ result = await fn(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/google/genai/_api_client.py", line 1325, in _async_request_once await errors.APIError.raise_for_async_response(response) File "/usr/local/lib/python3.12/site-packages/google/genai/errors.py", line 216, in raise_for_async_response await cls.raise_error_async(status_code, response_json, response) File "/usr/local/lib/python3.12/site-packages/google/genai/errors.py", line 238, in raise_error_async raise ClientError(status_code, response_json, response) google.genai.errors.ClientError: 400 INVALID_ARGUMENT. {'error': {'code': 400, 'message': '* GenerateContentRequest.tools[0].function_declarations[9].parameters.properties[source_uuids].items: missing field.\n', 'status': 'INVALID_ARGUMENT'}}
Are you willing to submit a PR? / 你愿意提交 PR 吗?
- Yes!
Code of Conduct
- I have read and agree to abide by the project's Code of Conduct。
Metadata
Metadata
Assignees
Labels
area:providerThe bug / feature is about AI Provider, Models, LLM Agent, LLM Agent Runner.The bug / feature is about AI Provider, Models, LLM Agent, LLM Agent Runner.bugSomething isn't workingSomething isn't working
Type
Projects
- StatusShow more project fieldsDone
Activity
[-][Bug] [Gemini] 客户端构造请求时的 schema错误[/-][+][Bug] [Gemini] 客户端构造请求时的 schema错误,导致LLM调用全部失败[/+]dosubot commentedon Mar 11, 2026
Hi @maodkaa! I'm Dosu and I’m helping the AstrBot team.
你好!这是一个已知的问题类型。v4.19.5 已经修复了大多数 Gemini Function Calling schema 问题,但仍有几种可能的原因:
可能原因:
tools字段,会返回 400 错误(相关 issue)gm_native_coderunner、gm_native_search等与自定义函数调用存在冲突建议排查步骤:
能否提供日志中的具体 API 错误响应?例如 400 错误的详细消息,这样可以更精确定位问题。
To reply, just mention @dosu.
Share context across your team and agents. Try Dosu.
madoka-chann commentedon Mar 11, 2026
如果不想看json的配置文件,这里提供图片版
dosubot commentedon Mar 11, 2026
感谢提供配置截图!看到问题了。
问题原因: 你启用了 Gemini 原生工具(代码执行、URL上下文),这些与 Function Calling 存在架构级不兼容(#1354)。启用原生工具后,所有自定义函数工具会被禁用,可能导致 schema 冲突错误。
另外,代码执行(Code execution)与 URL上下文(URL Context)不能同时开启(#1678),这是 Google API 的限制。
解决方案:
在 Gemini 提供商配置中关闭以下选项:
gm_native_coderunner(代码执行)gm_url_context(URL 上下文)gm_native_search(如有启用)关闭后 Function Calling 应该能正常工作(#4699)。如果之前有历史对话,建议也清理一下上下文。
To reply, just mention @dosu.
Share context across your team and agents. Try Dosu.
madoka-chann commentedon Mar 11, 2026
启用原生代码执行器可以修复,应该是新版本出现的问题。
madoka-chann commentedon Mar 11, 2026
该日志表示 Gemini API 请求参数格式错误,属于客户端构造请求时的 schema 问题,而不是模型本身的问题。
核心错误:
1. 错误含义
Gemini 在校验 tool function schema 时发现:
也就是说你在定义 tool function 参数时,声明了一个 array 类型字段
source_uuids,但没有给items指定类型。Gemini 的函数调用 schema 必须完整声明数组元素类型。
2. 错误示例(错误写法)
类似这种:
{ "type": "object", "properties": { "source_uuids": { "type": "array", "items": {} } } }或者
都会触发这个错误。
3. 正确写法
必须明确指定
items.type:{ "type": "object", "properties": { "source_uuids": { "type": "array", "items": { "type": "string" } } } }如果是 UUID:
4. 为什么所有 Gemini 模型都失败
日志里可以看到:
全部失败。
原因:
请求 payload 本身非法,所以换模型也没用。
5. 触发位置
根据日志:
说明:
source_uuids大概率是:
6. 修复方法
检查 tool 定义代码,例如:
找到类似:
改成:
7. 一句话总结
这个报错的本质:
不是模型问题,是 tool schema bug。
如果你愿意,可以把 AstrBot 的 tool schema 或 plugin 代码发出来,我可以帮你直接定位是哪一段写错了。
whatevertogo commentedon Mar 11, 2026
为了定位问题所在,你能否告诉我开个新对话是否能好呢
madoka-chann commentedon Mar 11, 2026
必须打开原生代码执行器才行
whatevertogo commentedon Mar 11, 2026
不好意思,我想再请问一下其他模型是好的吗,只有Gemini出现这个错误吗,尤其是deepseek,能用deepseek再测一下最好不过了
madoka-chann commentedon Mar 11, 2026
whatevertogo commentedon Mar 11, 2026
那就是工具的问题w(゚Д゚)w我回去看看吧
madoka-chann commentedon Mar 11, 2026
deepseek第三方的api没问题
madoka-chann commentedon Mar 11, 2026
kimi应该也没问题?你可以用iflow的模型自己试试
whatevertogo commentedon Mar 11, 2026
Σ( ° △ °|||)︴应该是你调用知识库工具调出来的东西损坏了?
madoka-chann commentedon Mar 11, 2026
zhengchalei commentedon Mar 12, 2026
自我进化 (Self-Evolution) 你看看是不是这个插件的问题。 我停用了就正常了
whatevertogo commentedon Mar 12, 2026
可能是的,调用数据库里面的信息不知道为什么混入了空格,请你向插件方提issue,这个插件维护者很好的,也是astrbot的维护者之一,关于这个issue你可以跟他讲一讲,他应该比我更懂这一块
madoka-chann commentedon Mar 12, 2026
madoka-chann commentedon Mar 12, 2026
ForceofwiII commentedon Mar 15, 2026
使用openai兼容api时出现相同问题