Skip to content

fix: function is not found in the tools_dict #2289

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

zakahan
Copy link

@zakahan zakahan commented Aug 1, 2025

fix issues #1532

Problem

This issue is caused by the following reasons:
When using certain models (such as doubao-1-5-pro-256k-250115) in the context of stream=True and tool invocation, an empty funciton_call may occur. Specifically, the name field of function_call is None or empty string. This PR resolves this bug by filtering this field in the function.
As shown in the figure:
image

Solution

Filter out empty function calls in advance in handle_function_calls_async

Testing plan

In the scenario of the current version (google-adk==1.9.0), when executing the following code using adk web (please add the two environment variables ark_api_key and api_base_url), this bug may be reproduced (not guaranteed, but highly likely).
I only tried this model and found that this bug can be reproduced relatively stably. For other issues mentioned in #1532, they should be similar, but I don't have his model.

import os
import random

from google.adk.agents import Agent
from google.adk.models.lite_llm import LiteLlm


def create_litellm_model(
    model: str = "doubao-1-5-pro-256k-250115",
    api_key: str = os.getenv("ARK_API_KEY"),
    api_base: str = os.getenv("API_BASE_URL")
):
    return LiteLlm(
        model=f"openai/{model}",
        api_key=api_key,
        api_base=api_base,
    )

def get_lucky_number():
    """
    Get a lucky number between 1 and 100.
    :return: int
    """
    return random.randint(1, 100)

root_agent = Agent(
    model = create_litellm_model(),
    name = "ChatBot",
    description="This is a chatbot",
    instruction="You are a chatbot and you can answer users' questions.",
    tools=[get_lucky_number],
)

Before fixing:
image

After fixing:
image

@zakahan zakahan changed the title fix: (issues #1532) function is not found in the tools_dict fix: function is not found in the tools_dict Aug 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant