Skip to content

Failed to parse the tool parameter #2232

@growmuye

Description

@growmuye

事故现场

复现代码

from google.adk import Agent

async def get_weather(local: str | None = None) -> str:
    """
    查询天气
    Returns:
        天气结果
    """
    return f"good day {local}"


root_agent = Agent(
    model=...,
    name="Assistant",
    description="你是一个AI助手",
    instruction="你是一个AI助手",
    tools=[get_weather],
)

错误信息

ValueError: Failed to parse the parameter local: str | None = None of function get_weather for automatic function calling. Automatic function calling works best with simpler function signature schema, consider manually parsing your function declaration for function get_weather.

临时处理方案

利用langChain转换

  • "google-adk==1.8.0",
  • "langchain==0.3.25"
from google.adk import Agent
from google.adk.tools.langchain_tool import LangchainTool
from langchain_core.tools import tool

@tool
async def get_weather(local: str | None = None) -> str:
    """
    查询天气
    Returns:
        天气结果
    """
    return f"good day {local}"


root_agent = Agent(
    model=...,
    name="Assistant",
    description="你是一个AI助手",
    instruction="你是一个AI助手",
    tools=[LangchainTool(get_weather)],
)

是否考虑将一些基础代码替换为langChain的?而不是自研

Metadata

Metadata

Assignees

Labels

bot triaged[Bot] This issue is triaged by ADK bottools[Component] This issue is related to tools

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions