Build and run agents you can see, understand and trust.
Python agentchatbotlarge-language-modelsllmllm-agentmcpmulti-agentmulti-modalreact-agentrealtime-agentvoice-agentvoice-assistant
fix(gemini): fix gemini schema containing null (#2020)
qbc0afecda06bc1
diff --git a/src/agentscope/model/_anthropic/_model.py b/src/agentscope/model/_anthropic/_model.pyindex 18cbb5835..f3b5e6d35 100644--- a/src/agentscope/model/_anthropic/_model.py+++ b/src/agentscope/model/_anthropic/_model.py@@ -285,12 +285,14 @@ class AnthropicChatModel(ChatModelBase):u,"cache_creation_input_tokens",0,- ),+ )+ or 0,cache_input_tokens=getattr(u,"cache_read_input_tokens",0,- ),+ )+ or 0,)resp_kwargs: dict[str, Any] = {diff --git a/src/agentscope/model/_gemini/_model.py b/src/agentscope/model/_gemini/_model.pyindex f221ea470..2df87188f 100644--- a/src/agentscope/model/_gemini/_model.py+++ b/src/agentscope/model/_gemini/_model.py@@ -55,6 +55,13 @@ def _sanitize_schema_for_gemini(schema: Any) -> Any:schema = dict(schema)+ # Gemini (and many third-party proxies) reject `null` as a standalone+ # functionDeclaration property type. Some MCP servers emit+ # {"type": "null"} directly (not wrapped in anyOf) for parameters that+ # accept None — rewrite it to "object" so it round-trips through the API.+ if schema.get("type") == "null":+ schema["type"] = "object"+# Remove additionalProperties — not supported by Geminischema.pop("additionalProperties", None)