Description
FunctionTool returns {"error": ...} when mandatory args are missing so the model can retry.
RestApiTool maps filled args into path_params, then does self.endpoint.path.format(**path_params) in _prepare_request_params. An omitted required path parameter leaves a template key unset → KeyError (original OpenAPI name, e.g. 'userId').
RestApiTool.call only catches TimeoutException / HTTPStatusError, so the agent invocation aborts instead of returning a retryable tool error.
Location: google/adk/tools/openapi_tool/openapi_spec_parser/rest_api_tool.py
Environment
google-adk==2.9.2
- Offline unit repro (no live HTTP)
Repro
# RestApiTool for path /users/{userId} with required path param userId / py_name user_id
# Call with args {} (or missing user_id)
# → KeyError: 'userId'
Observed (google-adk==2.9.2)
- path
/users/{userId}, args {} → KeyError: 'userId'
py_names for the param include user_id (declaration expects snake_case), but missing value still crashes via format
Expected
Missing required path params should return a structured tool error (mirror FunctionTool._get_mandatory_args) so the model can retry, not abort the agent run.
Suggested fix
Before format, verify every {placeholder} in the path is present; on miss return {"error": "missing path parameter …"}. Optionally catch KeyError/ValueError from _prepare_request_params in call.
Notes
Nearby RestApiTool crashes #7164 (header type) and #7206 (non-UTF-8 body) are different sites. Happy to open a PR.
Description
FunctionToolreturns{"error": ...}when mandatory args are missing so the model can retry.RestApiToolmaps filled args intopath_params, then doesself.endpoint.path.format(**path_params)in_prepare_request_params. An omitted required path parameter leaves a template key unset →KeyError(original OpenAPI name, e.g.'userId').RestApiTool.callonly catchesTimeoutException/HTTPStatusError, so the agent invocation aborts instead of returning a retryable tool error.Location:
google/adk/tools/openapi_tool/openapi_spec_parser/rest_api_tool.pyEnvironment
google-adk==2.9.2Repro
Observed (
google-adk==2.9.2)/users/{userId}, args{}→KeyError: 'userId'py_namesfor the param includeuser_id(declaration expects snake_case), but missing value still crashes viaformatExpected
Missing required path params should return a structured tool error (mirror
FunctionTool._get_mandatory_args) so the model can retry, not abort the agent run.Suggested fix
Before
format, verify every{placeholder}in the path is present; on miss return{"error": "missing path parameter …"}. Optionally catchKeyError/ValueErrorfrom_prepare_request_paramsincall.Notes
Nearby RestApiTool crashes #7164 (header type) and #7206 (non-UTF-8 body) are different sites. Happy to open a PR.