Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Automatic function calling fails on adk run/web, but works with a custom client #3543

@danicat

Description

@danicat

Recently adk run and adk web started failing for me with the error below:

Failed to parse the parameter item: sqlite_rag.models.document_result.DocumentResult of function search_query_library for automatic function calling. Automatic function calling works best with simpler function signature schema, consider manually parsing your function declaration for function search_query_library.

This is the full definition of search_query_library:

def search_query_library(search_terms: str, platform: str, top_k: int) -> list[DocumentResult]:
    """
    Search the query pack library to find relevant queries corresponding to the
    search terms. For better response quality, use the platform argument to
    specify which platform you are currently investigating (e.g. darwin) 

    Arguments:
        search_terms    Can be either a table name, like "system_info", or one
                        or more search terms like "malware detection".
        platform        One of "linux", "darwin", "windows" or "all"
        top_k           Number of top results to search in both semantic and FTS
                        search. Number of documents may be higher.

    Returns:
        One or more chunks of data containing the related queries.
    """

    if platform == "all" or platform is None:
        search_terms += " windows linux darwin"
    else:
        search_terms += " " + platform

    results = queries_rag.search(search_terms, top_k=top_k)
    return results

The issue is, if I run it with a custom runner, there are no problems with the tool and it is able to call it normally:

import asyncio
import sys
from aida.agent import root_agent
from google.adk.runners import InMemoryRunner
from google.adk.runners import types
from dotenv import load_dotenv

load_dotenv()

async def main():
    # Initialize runner with the agent
    runner = InMemoryRunner(agent=root_agent)
    
    # Create a session. We use the runner's app_name to ensure compatibility.
    await runner.session_service.create_session(
        user_id="repro_user", 
        session_id="repro_session", 
        app_name=runner.app_name
    )

    prompt = "show me the first query for malware diagnostics (k=1)"
    print(f"Sending prompt: '{prompt}'")
    
    message = types.Content(role="user", parts=[types.Part(text=prompt)])

    try:
        async for event in runner.run_async(
            user_id="repro_user", 
            session_id="repro_session", 
            new_message=message
        ):
            # Print the response text
            if event.is_final_response() and event.content and event.content.parts:
                for part in event.content.parts:
                    if part.text:
                        print(part.text)
            
    except Exception as e:
        print(f"\nCaught error:\n{e}")
        # We expect a ValueError here if the bug is reproduced
        sys.exit(1)

    print("Finished successfully.")

if __name__ == "__main__":
    asyncio.run(main())

Running this script results in this output:

$ uv run reproduce.py
App name mismatch detected. The runner is configured with app name "InMemoryRunner", but the root agent was loaded from "/Users/petruzalek/projects/aida/.venv/lib/python3.12/site-packages/google/adk/agents", which implies app name "agents".
Sending prompt: 'show me the first query for malware diagnostics (k=1)'
Warning: there are non-text parts in the response: ['function_call'], returning concatenated text result from text parts. Check the full candidates.content.parts accessor to get the full model response.
I found a query for malware diagnostics:

**Name:** OSX_Dummy_Launchd
**Description:** OSX Dummy Malware (https://objective-see.com/blog/blog_0x32.html and https://isc.sans.edu/diary/23816)
**Rationale:** Artifacts created by this malware
**SQL:** `SELECT * FROM launchd WHERE name = 'com.startup.plist';`
Finished successfully.

To Reproduce

git clone https://github.com/danicat/aida.git && cd aida
cat <<EOF > aida/.env
GOOGLE_GENAI_USE_VERTEXAI=1
GOOGLE_CLOUD_PROJECT=your-test-project-id
GOOGLE_CLOUD_LOCATION=global
EOF
./setup.sh
uv run adk run aida

Type the prompt: "hello". The agent will crash with the automatic function call error. Same problem is reproducible invoking the agent from ADK web.

Now run uv run reproduce.py. The agent will respond normally without crashing.

Expected behavior
ADK web and ADK run should not fail in this scenario.

Desktop (please complete the following information):

  • OS: macOS
  • Python version(python -V): 3.12 and 3.14
  • ADK version(pip show google-adk): 1.18

Model Information:

  • Are you using LiteLLM: No
  • Which model is being used(e.g. gemini-2.5-pro): gemini-2.5-flash

Additional context
N/A

Metadata

Metadata

Assignees

Labels

core[Component] This issue is related to the core interface and implementation

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions