vLLM unable to use tool calls properly
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:
- google-adk
- 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:
ollama endpoint:
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
I have the same problem!
@selcukgun or @genquan9 to help take a look.
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?
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.
please feel free to re-open this issue if there are further issues.
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:
- google-adk
- 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:
ollama endpoint:
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?