Schema Issue: "schema specified other fields alongside any_of" #876
Replies: 1 comment
-
Ended up figuring this out shortly after making this post. For anyone else running into this issue, my solution was the following: import os Your exact logic adapted for ADK 1.0.0def make_tools_gemini_compatible(tools):
Subclass MCPToolset to apply patch lazily and safelyclass PatchedMCPToolset(MCPToolset):
MCPToolset with custom patching_allowed_path = os.path.join( toolset = PatchedMCPToolset( root_agent = LlmAgent( |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm currently running into an issue with schemas for ADK version 1.0.0, the error message is as follows:
raise ClientError(status_code, response_json, response)
google.genai.errors.ClientError: 400 INVALID_ARGUMENT. {'error': {'code': 400, 'message': 'Unable to submit request because
do_update_security_alert
functionDeclarationparameters.status
schema specified other fields alongside any_of. When using any_of, it must be the only field set.I ran into this issue on version 0.4.0 and 0.5.0 and was able to get around it by passing in MCP tools to this function:
def make_tools_gemini_compatible(tools):
"""
This function makes the schema compatible with Gemini/Vertex AI API
It is only needed when API used is Gemini and model is other than 2.5 models
It is however needed for ALL models when API used is VertexAI
"""
for tool in tools:
for key in tool.mcp_tool.inputSchema.keys():
if key == "properties":
for prop_name in tool.mcp_tool.inputSchema["properties"].keys():
if "anyOf" in tool.mcp_tool.inputSchema["properties"][prop_name].keys():
if (tool.mcp_tool.inputSchema["properties"][prop_name]["anyOf"][0]["type"] == "array"):
tool.mcp_tool.inputSchema["properties"][prop_name]["type"] = tool.mcp_tool.inputSchema["properties"][prop_name]["anyOf"][0]["items"]["type"]
else:
tool.mcp_tool.inputSchema["properties"][prop_name]["type"] = tool.mcp_tool.inputSchema["properties"][prop_name]["anyOf"][0]["type"]
tool.mcp_tool.inputSchema["properties"][prop_name].pop("anyOf")
return tools
Unfortunately, now with version 1.0.0 I am unable to use this workaround. Is there a working example of another workaround that can be used to make tools gemini compatible that works with 1.0.0?
Beta Was this translation helpful? Give feedback.
All reactions