adk-python icon indicating copy to clipboard operation
adk-python copied to clipboard

vLLM unable to use tool calls properly

Open liatoutou opened this issue 1 year ago • 6 comments

Describe the bug When replacing my ollama model with the same version model but served through vllm the pipeline doesnt work anymore

To Reproduce install:

  1. google-adk
  2. litellm

run:

adk web

This is the code that works:

from google.genai import types

from google.adk.agents import Agent
from google.adk.agents.callback_context import CallbackContext
from google.adk.tools import load_artifacts
from google.adk.models.lite_llm import LiteLlm


from .prompts import return_instructions_root
from .tools import call_mr_agent, call_jd_agent
from .sub_agents.model.tools import search_models

def setup_before_agent_call(callback_context: CallbackContext):
    """Setup the agent."""

    # Initialize query_history for model requirement tracking
    if "query_history" not in callback_context.state:
        callback_context.state["query_history"] = ""


root_agent = Agent(
    model=LiteLlm(model='ollama_chat/mistral-small3.1'),
    name="deployment_manager_agent",
    instruction=return_instructions_root(),
    tools=[
        call_mr_agent,
        search_models,
        load_artifacts,
        call_jd_agent,
    ],
    before_agent_callback=setup_before_agent_call,
    generate_content_config=types.GenerateContentConfig(temperature=0.00),
)

This is the code that doesnt work:

from google.genai import types

from google.adk.agents import Agent
from google.adk.agents.callback_context import CallbackContext
from google.adk.tools import load_artifacts
from google.adk.models.lite_llm import LiteLlm


from .prompts import return_instructions_root
from .tools import call_mr_agent, call_jd_agent
from .sub_agents.model.tools import search_models

api_base_url = "https://4KsXonMwuwZZ7Mvvd1ZGHZu1VeWqdXW5BRJgbtHkzXMh.node.k8s.prd.nos.ci/v1"

model_name_at_endpoint = "vllm_hosted/Mistral-Small"

def setup_before_agent_call(callback_context: CallbackContext):
    """Setup the agent."""

    # Initialize query_history for model requirement tracking
    if "query_history" not in callback_context.state:
        callback_context.state["query_history"] = ""


root_agent = Agent(
     model=LiteLlm(
        model=f"openai/{model_name_at_endpoint}",
        api_base=api_base_url,
        api_key="YOUR_ENDPOINT_API_KEY"
    ),
    name="deployment_manager_agent",
    instruction=return_instructions_root(),
    tools=[
        call_mr_agent,
        search_models,
        load_artifacts,
        call_jd_agent,
    ],
    before_agent_callback=setup_before_agent_call,
    generate_content_config=types.GenerateContentConfig(temperature=0.00),
)

Expected behavior A clear and concise description of what you expected to happen.

Screenshots vLLM endpoint: Image

ollama endpoint:

Image

Desktop (please complete the following information):

  • OS: [e.g. iOS] Windows
  • Python version(python -V): 3.12.4
  • ADK version(pip show google-adk): 2.0

liatoutou avatar Apr 23 '25 07:04 liatoutou

I have the same problem!

ngothetai avatar May 09 '25 04:05 ngothetai

@selcukgun or @genquan9 to help take a look.

hangfei avatar May 31 '25 18:05 hangfei

could you share the deployment settings when you deploy the mistral-small? did you follow https://google.github.io/adk-docs/agents/models/#debugging to deploy the model properly?

genquan9 avatar Jun 03 '25 21:06 genquan9

btw, we also have some examples to self deploy models to vertex ai, and then integrate with agent in https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/community/model_garden/model_garden_integration_with_agent.ipynb.

genquan9 avatar Jun 03 '25 21:06 genquan9

please feel free to re-open this issue if there are further issues.

genquan9 avatar Jun 16 '25 20:06 genquan9

Describe the bug When replacing my ollama model with the same version model but served through vllm the pipeline doesnt work anymore

To Reproduce install:

  1. google-adk
  2. litellm

run:

adk web

This is the code that works:

from google.genai import types

from google.adk.agents import Agent
from google.adk.agents.callback_context import CallbackContext
from google.adk.tools import load_artifacts
from google.adk.models.lite_llm import LiteLlm


from .prompts import return_instructions_root
from .tools import call_mr_agent, call_jd_agent
from .sub_agents.model.tools import search_models

def setup_before_agent_call(callback_context: CallbackContext):
    """Setup the agent."""

    # Initialize query_history for model requirement tracking
    if "query_history" not in callback_context.state:
        callback_context.state["query_history"] = ""


root_agent = Agent(
    model=LiteLlm(model='ollama_chat/mistral-small3.1'),
    name="deployment_manager_agent",
    instruction=return_instructions_root(),
    tools=[
        call_mr_agent,
        search_models,
        load_artifacts,
        call_jd_agent,
    ],
    before_agent_callback=setup_before_agent_call,
    generate_content_config=types.GenerateContentConfig(temperature=0.00),
)

This is the code that doesnt work:

from google.genai import types

from google.adk.agents import Agent
from google.adk.agents.callback_context import CallbackContext
from google.adk.tools import load_artifacts
from google.adk.models.lite_llm import LiteLlm


from .prompts import return_instructions_root
from .tools import call_mr_agent, call_jd_agent
from .sub_agents.model.tools import search_models

api_base_url = "https://4KsXonMwuwZZ7Mvvd1ZGHZu1VeWqdXW5BRJgbtHkzXMh.node.k8s.prd.nos.ci/v1"

model_name_at_endpoint = "vllm_hosted/Mistral-Small"

def setup_before_agent_call(callback_context: CallbackContext):
    """Setup the agent."""

    # Initialize query_history for model requirement tracking
    if "query_history" not in callback_context.state:
        callback_context.state["query_history"] = ""


root_agent = Agent(
     model=LiteLlm(
        model=f"openai/{model_name_at_endpoint}",
        api_base=api_base_url,
        api_key="YOUR_ENDPOINT_API_KEY"
    ),
    name="deployment_manager_agent",
    instruction=return_instructions_root(),
    tools=[
        call_mr_agent,
        search_models,
        load_artifacts,
        call_jd_agent,
    ],
    before_agent_callback=setup_before_agent_call,
    generate_content_config=types.GenerateContentConfig(temperature=0.00),
)

Expected behavior A clear and concise description of what you expected to happen.

Screenshots vLLM endpoint: Image

ollama endpoint:

Image

Desktop (please complete the following information):

  • OS: [e.g. iOS] Windows
  • Python version(python -V): 3.12.4
  • ADK version(pip show google-adk): 2.0

Have you solve it?

wangjl1993 avatar Jul 17 '25 09:07 wangjl1993