Repository navigation
Closed
Labels
core[Component] This issue is related to the core interface and implementation
Milestone
Description
Describe the bug
I am trying to dynamically generate tools for a Kubernetes agent based on the Kubernetes python client. When using the agent in the adk dev UI I get an error.
To Reproduce
Steps to reproduce the behavior:
- Install latest version of adk (as of today)
- Run 'adk web`
- Ask 'list namespaces on my cluster`
- See error
2025-04-19 11:07:11,906 - ERROR - fast_api.py:637 - Error in event_generator: Failed to parse the parameter namespace: 'str' of function namespaced_lister for automatic function calling. Automatic function calling works best with simpler function signature schema,consider manually parse your function declaration for function namespaced_lister.
Traceback (most recent call last):
File "/Users/mikebz/src/adk-kube/.venv/lib/python3.11/site-packages/google/adk/cli/fast_api.py", line 626, in event_generator
async for event in runner.run_async(
File "/Users/mikebz/src/adk-kube/.venv/lib/python3.11/site-packages/google/adk/runners.py", line 197, in run_async
async for event in invocation_context.agent.run_async(invocation_context):
File "/Users/mikebz/src/adk-kube/.venv/lib/python3.11/site-packages/google/adk/agents/base_agent.py", line 141, in run_async
async for event in self._run_async_impl(ctx):
File "/Users/mikebz/src/adk-kube/.venv/lib/python3.11/site-packages/google/adk/agents/llm_agent.py", line 232, in _run_async_impl
async for event in self._llm_flow.run_async(ctx):
File "/Users/mikebz/src/adk-kube/.venv/lib/python3.11/site-packages/google/adk/flows/llm_flows/base_llm_flow.py", line 231, in run_async
async for event in self._run_one_step_async(invocation_context):
File "/Users/mikebz/src/adk-kube/.venv/lib/python3.11/site-packages/google/adk/flows/llm_flows/base_llm_flow.py", line 245, in _run_one_step_async
async for event in self._preprocess_async(invocation_context, llm_request):
File "/Users/mikebz/src/adk-kube/.venv/lib/python3.11/site-packages/google/adk/flows/llm_flows/base_llm_flow.py", line 283, in _preprocess_async
await tool.process_llm_request(
File "/Users/mikebz/src/adk-kube/.venv/lib/python3.11/site-packages/google/adk/tools/base_tool.py", line 96, in process_llm_request
if (function_declaration := self._get_declaration()) is None:
^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/mikebz/src/adk-kube/.venv/lib/python3.11/site-packages/google/adk/tools/function_tool.py", line 42, in _get_declaration
build_function_declaration(
File "/Users/mikebz/src/adk-kube/.venv/lib/python3.11/site-packages/google/adk/tools/_automatic_function_calling_util.py", line 232, in build_function_declaration
from_function_with_options(func, variant)
File "/Users/mikebz/src/adk-kube/.venv/lib/python3.11/site-packages/google/adk/tools/_automatic_function_calling_util.py", line 309, in from_function_with_options
schema = function_parameter_parse_util._parse_schema_from_parameter(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/mikebz/src/adk-kube/.venv/lib/python3.11/site-packages/google/adk/tools/function_parameter_parse_util.py", line 292, in _parse_schema_from_parameter
raise ValueError(
ValueError: Failed to parse the parameter namespace: 'str' of function namespaced_lister for automatic function calling. Automatic function calling works best with simpler function signature schema,consider manually parse your function declaration for function namespaced_lister.
Expected behavior
Call happens to my cluster.
Desktop (please complete the following information):
- OS: MacOS
- Python version(python -V): Python 3.11.9
- ADK version(pip show google-adk):
Name: google-adk
Version: 0.2.0
Location: /Users/mikebz/src/adk-kube/.venv/lib/python3.11/site-packages
Requires: authlib, click, fastapi, google-api-python-client, google-cloud-aiplatform, google-cloud-secret-manager, google-cloud-speech, google-cloud-storage, google-genai, graphviz, mcp, opentelemetry-api, opentelemetry-exporter-gcp-trace, opentelemetry-sdk, pydantic, python-dotenv, pyyaml, sqlalchemy, tzlocal, uvicorn
Required-by:
Additional context
Add any other context about the problem here.
Tools are generated like this:
def namespaced_lister_tool(method_name: str) -> Callable[[str], dict]:
"""
Create a namespaced lister function for a specific Kubernetes resource.
Args:
name: The method name to call on the CoreV1Api client.
Returns:
An async function that lists the specified resource in a namespace.
"""
async def namespaced_lister(namespace: str) -> dict:
"""List the specified Kubernetes resource in a namespace.
Args:
namespace (str): The namespace to list the resource in.
Returns:
A list of resource names.
"""
v1 = client.CoreV1Api()
method = getattr(v1, method_name)
items = method(namespace)
result = [item.metadata.name for item in items.items]
return {
"status": "success",
"names": result,
}
return namespaced_lister
Agent is declared like this:
from google.adk.agents import Agent
import kube as k8s
root_agent = Agent(
name="kubernetes_agent",
model="gemini-2.0-flash",
description=(
"Agent that can interact with Kubernetes clusters"
),
instruction=(
"You are a Kubernetes agent. You can interact with Kubernetes "
"clusters, answer questions about Kubernetes, and provide information "
"about Kubernetes resources. You can also provide information about "
"the Kubernetes API and how to use it. You can also provide "
"information about the Kubernetes CLI and how to use it."
),
tools=k8s.all_tools()
)
Metadata
Metadata
Assignees
Labels
core[Component] This issue is related to the core interface and implementation
Activity
hangfei commentedon Apr 28, 2025
Function calling(or tools) only supports dict of primitive types as return value so that models can understand.
You should convert that into a string or dict for models to understand.
mikebz commentedon Apr 28, 2025
@hangfei thank you! This is the function declaration, is the issue that there can be nested dictionaries?
Ahaskar04 commentedon May 14, 2025
Hey, I ran into this exact error too, but not with a lambda function.
In my case, the issue was caused by:
from __future__ import annotationsThis defers evaluation of type hints (e.g. expression: str becomes 'str' at runtime), which causes ADK’s function parser to choke with the same exact error:
Failed to parse the parameter expression: 'str' of function ...Once I removed that line, the automatic function calling worked perfectly.
Key points:
KaRtHiK-56 commentedon May 21, 2025
i was experimenting to use functional tools using my custom python function to test google ADK, i know we can use google_search tool to get weather too, but to test custom function as tool , i want to know on this
Ran into this error:
{"error": "Failed to parse the parameter city of function weather_teller for automatic function calling. Automatic function calling works best with simpler function signature schema, consider manually parsing your function declaration for function weather_teller."}
wuliang229 commentedon May 28, 2025
@KaRtHiK-56 I couldn't reproduce your issue with the exact same code using the latest ADK version. I could see the error only if I add
from __future__ import annotationslike the other users mentioned.wuliang229 commentedon May 28, 2025
@mikebz I tried copying your code structure with how the tool is defined, but I couldn't reproduce. Did you happen to use
from __future__ import annotationsin your code too?wuliang229 commentedon May 29, 2025
This commit should fix this issue. Please re-open if you see this issue again.
psbanka commentedon Aug 12, 2025
I'm still seeing this problem as of ADK version
1.10.0.fix(bqaa): put C7 pair keys under attributes.adk (not top-level)
docs(bqaa): fix _build_adk_envelope docstring — keys are omitted, not…