Repository navigation
Description
Describe the Bug:
RestApiTool._get_declaration() builds the FunctionDeclaration from the operation's parameters only. The operation's 2xx response schema is never added, so response_json_schema is always None for tools generated by OpenAPIToolset.
The schema is already parsed: OperationParser._process_return_value() reads the smallest 2xx response and stores it as the parser's return value (get_return_value()), and ParsedOperation.return_value carries it. It just never reaches the declaration.
McpTool already does this: with JSON_SCHEMA_FOR_FUNC_DECL on (the default), McpTool._build_declaration() sets response_json_schema from the MCP tool's outputSchema. #2828 asked for the same on the MCP side, and #6815 (which #7054 was closed in favor of) forwards a declaration's output schema on the LiteLLM path too, so the model side already uses it when a tool provides one.
Without it, the model can't see what an OpenAPI tool returns (field names, which fields are always present, array vs object) until after it has called it. Code that reads tool declarations, for example to generate typed wrappers, can't see it either.
Steps to Reproduce:
from google.adk.tools.openapi_tool import OpenAPIToolset
spec = {
"openapi": "3.0.0",
"info": {"title": "Pet Store", "version": "1.0.0"},
"servers": [{"url": "https://petstore.example.com"}],
"paths": {
"/pets/{petId}/toys": {
"get": {
"operationId": "listToys",
"parameters": [{
"name": "petId",
"in": "path",
"required": True,
"schema": {"type": "string"},
}],
"responses": {
"200": {
"description": "The pet's toys.",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {"type": "string"},
"name": {"type": "string"},
},
"required": ["id", "name"],
},
}
}
},
}
},
}
}
},
}
tool = OpenAPIToolset(spec_dict=spec).get_tool("list_toys")
declaration = tool._get_declaration()
print(declaration.response_json_schema)
print(tool._operation_parser.get_return_value().param_schema.model_dump(exclude_none=True))Expected Behavior:
declaration.response_json_schema is the 200 response schema (the array of toys), as it is for an MCP tool with an outputSchema.
Observed Behavior:
None
{'items': {'properties': {'id': {'type': 'string'}, 'name': {'type': 'string'}}, 'type': 'object', 'required': ['id', 'name']}, 'type': 'array'}
The declaration has no response schema, even though the parser holds it.
Proposed fix:
In the JSON_SCHEMA_FOR_FUNC_DECL branch of RestApiTool._get_declaration(), set response_json_schema from the parsed 2xx response schema (None when the operation doesn't declare one), mirroring McpTool. The legacy parameters= branch would stay as it is, also mirroring McpTool. I'm happy to open a PR.
Environment Details:
- ADK Library Version:
main(2.14.0) - Desktop OS: macOS
- Python Version: 3.12
Model Information:
- Are you using LiteLLM: N/A (the declaration is built before any model call)
- Which model is being used: N/A
How often has this issue occurred?:
- Always (100%)
Activity
llalitkumarrr commentedon Nov 12, 2026
Hello @benclarkeio,
Thank you for your request and your contribution. Your PR is currently under review and we will reach out if we need further information. In the meantime, we appreciate your patience.