-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
tools[Component] This issue is related to tools[Component] This issue is related to tools
Milestone
Description
Agent Cant use tool
400, message='Bad Request', url='http://127.0.0.1:5000/api/tool/list-configs/invoke'
tools.yaml
sources:
my-bigquery-source:
kind: bigquery
project: civic-advantage-202916
location: us
tools:
list-configs:
kind: bigquery-sql
source: my-bigquery-source
description: search for tables that i the user have access.
parameters:
- name: name
type: string
description: The name of the hotel.
statement: SELECT table_name FROM `civic-advantage-202916.user.INFORMATION_SCHEMA.TABLES`;
toolsets:
my-toolset:
- list-configs
agent.py
`from google.adk.agents import Agent
from google.adk.tools.toolbox_tool import ToolboxTool
from google.adk.runners import Runner
from google.adk.sessions import InMemorySessionService
from google.adk.artifacts.in_memory_artifact_service import InMemoryArtifactService
from google.genai import types # For constructing message content
import os
os.environ['GOOGLE_GENAI_USE_VERTEXAI'] = 'True'
# TODO(developer): Replace 'YOUR_PROJECT_ID' with your Google Cloud Project ID.
os.environ['GOOGLE_CLOUD_PROJECT'] = 'civic-advantage-202916'
# TODO(developer): Replace 'us-central1' with your Google Cloud Location (region).
os.environ['GOOGLE_CLOUD_LOCATION'] = 'us-central1'
# --- Load Tools from Toolbox ---
# TODO(developer): Ensure the Toolbox server is running at http://127.0.0.1:5000
toolbox_tools = ToolboxTool("http://127.0.0.1:5000")
# --- Define the Agent's Prompt ---
prompt = """
You can list tables that the user have access on bigquery.
"""
# --- Configure the Agent ---
# TODO(developer): Replace "my-toolset" with the actual ID of your toolset as configured in your GenAI Toolbox server.
agent_toolset = toolbox_tools.get_toolset("my-toolset")
root_agent = Agent(
model='gemini-2.0-flash',
name='mcp_agent_bigquery',
description='You can list tables that the user have access on bigquery.',
instruction=prompt,
tools=agent_toolset, # Pass the loaded toolset
)
# --- Initialize Services for Running the Agent ---
session_service = InMemorySessionService()
artifacts_service = InMemoryArtifactService()
# Create a new session for the interaction.
session = session_service.create_session(
state={}, app_name='hotel_agent', user_id='123'
)
runner = Runner(
app_name='hotel_agent',
agent=root_agent,
artifact_service=artifacts_service,
session_service=session_service,
)
# --- Define Queries and Run the Agent ---
queries = [
"Find hotels in Basel with Basel in it's name.",
"Can you book the Hilton Basel for me?",
"Oh wait, this is too expensive. Please cancel it and book the Hyatt Regency instead.",
"My check in dates would be from April 10, 2024 to April 19, 2024.",
]
for query in queries:
content = types.Content(role='user', parts=[types.Part(text=query)])
events = runner.run(session_id=session.id,
user_id='123', new_message=content)
responses = (
part.text
for event in events
for part in event.content.parts
if part.text is not None
)
for text in responses:
print(text)
`
To Reproduce
./toolbox --tools-file "tools.yaml"
adk web
Expected behavior
The agent should be able to call list-configs tool
Screenshots
A weird thing is that on mcp inspector i can see the tool and invoke it
Desktop (please complete the following information):
- OS: Ubuntu/Linux
- Python version(python -V): 3.12.2
- ADK version(pip show google-adk): 0.4.0
Metadata
Metadata
Assignees
Labels
tools[Component] This issue is related to tools[Component] This issue is related to tools