Description
Describe the bug
The Google API tool converter uses the _extract_path_parameters method to extract string parameters. It fails to parse path parameters in endpoint patterns like /v1/documents/{documentId}:batchUpdate
. The method looks for URL segments that start with { and end with }, but in patterns like {documentId}:batchUpdate
, the segment ends with :batchUpdate, not }, causing the parameter extraction to fail.
Error received in UI:
{"error": "'documentId'"}
Error in terminal:
\google\adk\tools\openapi_tool\openapi_spec_parser\rest_api_tool.py", line 283, in _prepare_request_params
url = f"{base_url}{self.endpoint.path.format(**path_params)}"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
KeyError: 'documentId'
2025-07-07 00:23:22,901 - ERROR - __init__.py:157 - Failed to detach context
To Reproduce
Steps to reproduce the behavior:
- Enable the Google Docs & Vertex APIs in Cloud Console
- Create OAuth credentials (use type Desktop)
- Create a basic ADK Agent (see below)
- Open the playground (make playground)
- Ask the agent to create a doc
- Authenticate
- Ask the agent to add text to the document
Repro Agent
import os
import google.auth
from google.adk.agents import Agent
from google.adk.tools.google_api_tool import DocsToolset
from googleapiclient.errors import HttpError
try:
_, project_id = google.auth.default()
os.environ.setdefault("GOOGLE_CLOUD_PROJECT", project_id)
os.environ.setdefault("GOOGLE_CLOUD_LOCATION", "global")
os.environ.setdefault("GOOGLE_GENAI_USE_VERTEXAI", "True")
# Validate environment variables
if not os.getenv("GOOGLE_OAUTH_CLIENT_ID") or not os.getenv("GOOGLE_OAUTH_CLIENT_SECRET"):
raise ValueError("GOOGLE_OAUTH_CLIENT_ID and GOOGLE_OAUTH_CLIENT_SECRET must be set")
docs_toolset = DocsToolset(
client_id=os.getenv("GOOGLE_OAUTH_CLIENT_ID"),
client_secret=os.getenv("GOOGLE_OAUTH_CLIENT_SECRET")
)
# Create the agent with Google Docs tools
root_agent = Agent(
name="root_agent",
model="gemini-2.0-flash",
instruction="You are a helpful AI assistant designed to use the good docs tool to create a documents.",
tools=[docs_toolset], # Pass as a list containing the toolset
)
except Exception as e:
print(f"Error type: {type(e)}")
print(f"Error args: {e.args}")
print(f"Error dict: {e.__dict__}")
raise
Expected behavior
Agents should be able to call the batchUpdate API in the Google Document spec
Desktop (please complete the following information):
- OS: Windows
- Python version(python -V): Python 3.12.4
- ADK version(pip show google-adk): 1.5.0
Model Information:
gemini-2.0-flash
Additional context
Assuming the location
parameter is correctly documented in the discovery apis, that could be used instead of extracting directly from the url string.