error - google adk google_search tools Built-in tools ({google_search}) and Function Calling cannot be combined in the same request. Please choose one to continue

Ran into this error while trying to setup my LLM agent to do tool calling. In this case, it is "google_search". 

in raise_error_async raise ClientError(status_code, response_json, response)

google.genai.errors.ClientError: 400 Bad Request. {'message': '{\n  "error": {\n    "code": 400,\n    "message": "Built-in tools ({google_search}) and Function Calling cannot be combined in the same request. Please choose one to continue.",\n    "status": "INVALID_ARGUMENT"\n  }\n}\n', 'status': 'Bad Request'}


The gist of the problem - ADK framework doesn't like me putting Agent model together with tool. 

To resolve this issue, I have change my agent from Agent (from google.adk import Agent ) to LlmAgent (from google.adk.agents import LlmAgent)

💥Error code     


researcher = Agent(
    name="researcher",
    model=model_name,
    description="Conducts research to gather information about incidents and errors.",
    instruction="""   
    """
    ),
    tools=[
        browser_tool, append_to_state,
    ],
)

💚  Fixed code 


researcher = LlmAgent(
    name="researcher",
    model=model_name,
    description="Conducts research to gather information about incidents and errors.",
    instruction="""   
    Based on the error try to determine the root and use the
provided link to load a webpage in html and understand what the error  
using the browser tool. You can also use the browser tool to load other relevant links to gather more information about the error. You will be an expert in interpreting html. Your goal is to travese to the link, gather as much information as possible about the error, in determining  root causes, and add findings  in to the state field 'research'.

    generate_content_config=types.GenerateContentConfig(
        temperature=0,
    ),
    tools=[
        google_search, append_to_state <--- additional tool possible too
    ],
    output_key="research_findings",
)

Looking at the code, Agent is really a type alias for. 

Agent: TypeAlias = LlmAgent





Comments

Popular posts from this blog

mongosh install properly

gemini cli getting file not defined error

vllm : Failed to infer device type