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()
)
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:
Expected behavior
Call happens to my cluster.
Desktop (please complete the following information):
Additional context
Add any other context about the problem here.
Tools are generated like this:
Agent is declared like this: