Skip to content

Commit 362ed8d

Browse files
authored
docs: migrate to toolbox-adk and simplified ToolboxToolset (googleapis#2211)
Updates all quickstart guides and samples to use the new `toolbox-adk` package instead of the legacy `toolbox-core`. Also updates `ToolboxToolset` usage to rely on the simplified constructor (implicit authentication) and ensures correct dependency installation. > [!NOTE] > The integration tests are failing because the `google-adk` package is not released yet with the newer changes from `toolbox-adk`. This is expected behavior until the [package update](cl/853799009) is released.
1 parent 293c1d6 commit 362ed8d

File tree

6 files changed

+68
-60
lines changed

6 files changed

+68
-60
lines changed

docs/en/getting-started/colab_quickstart.ipynb

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -520,8 +520,7 @@
520520
},
521521
"outputs": [],
522522
"source": [
523-
"! pip install toolbox-core --quiet\n",
524-
"! pip install google-adk --quiet"
523+
"! pip install google-adk[toolbox] --quiet"
525524
]
526525
},
527526
{
@@ -536,14 +535,18 @@
536535
"from google.adk.runners import Runner\n",
537536
"from google.adk.sessions import InMemorySessionService\n",
538537
"from google.adk.artifacts.in_memory_artifact_service import InMemoryArtifactService\n",
538+
"from google.adk.tools.toolbox_toolset import ToolboxToolset\n",
539539
"from google.genai import types\n",
540-
"from toolbox_core import ToolboxSyncClient\n",
541540
"\n",
542541
"import os\n",
543542
"# TODO(developer): replace this with your Google API key\n",
544543
"os.environ['GOOGLE_API_KEY'] = \"<GOOGLE_API_KEY>\"\n",
545544
"\n",
546-
"toolbox_client = ToolboxSyncClient(\"http://127.0.0.1:5000\")\n",
545+
"# Configure toolset\n",
546+
"toolset = ToolboxToolset(\n",
547+
" server_url=\"http://127.0.0.1:5000\",\n",
548+
" toolset_name=\"my-toolset\"\n",
549+
")\n",
547550
"\n",
548551
"prompt = \"\"\"\n",
549552
" You're a helpful hotel assistant. You handle hotel searching, booking and\n",
@@ -560,7 +563,7 @@
560563
" name='hotel_agent',\n",
561564
" description='A helpful AI assistant.',\n",
562565
" instruction=prompt,\n",
563-
" tools=toolbox_client.load_toolset(\"my-toolset\"),\n",
566+
" tools=[toolset],\n",
564567
")\n",
565568
"\n",
566569
"session_service = InMemorySessionService()\n",

docs/en/getting-started/local_quickstart.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ runtime](https://research.google.com/colaboratory/local-runtimes.html).
5252
{{< tabpane persist=header >}}
5353
{{< tab header="ADK" lang="bash" >}}
5454

55-
pip install toolbox-core
55+
pip install google-adk[toolbox]
5656
{{< /tab >}}
5757
{{< tab header="Langchain" lang="bash" >}}
5858

@@ -73,7 +73,7 @@ pip install toolbox-core
7373
{{< tabpane persist=header >}}
7474
{{< tab header="ADK" lang="bash" >}}
7575

76-
pip install google-adk
76+
# No other dependencies required for ADK
7777
{{< /tab >}}
7878
{{< tab header="Langchain" lang="bash" >}}
7979

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
from google.adk import Agent
22
from google.adk.apps import App
3-
from toolbox_core import ToolboxSyncClient
3+
from google.adk.tools.toolbox_toolset import ToolboxToolset
44

55
# TODO(developer): update the TOOLBOX_URL to your toolbox endpoint
6-
client = ToolboxSyncClient("http://127.0.0.1:5000")
6+
toolset = ToolboxToolset(
7+
server_url="http://127.0.0.1:5000",
8+
)
79

810
root_agent = Agent(
911
name='root_agent',
1012
model='gemini-2.5-flash',
1113
instruction="You are a helpful AI assistant designed to provide accurate and useful information.",
12-
tools=client.load_toolset(),
14+
tools=[toolset],
1315
)
1416

1517
app = App(root_agent=root_agent, name="my_agent")
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
google-adk==1.21.0
2-
toolbox-core==0.5.4
1+
google-adk[toolbox]==1.23.0
32
pytest==9.0.2

docs/en/how-to/deploy_adk_agent.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ with the necessary configuration for deployment to Vertex AI Agent Engine.
4646
process will generate deployment configuration files (like a `Makefile` and
4747
`Dockerfile`) in your project directory.
4848

49-
4. Add `toolbox-core` as a dependency to the new project:
49+
4. Add `google-adk[toolbox]` as a dependency to the new project:
5050

5151
```bash
52-
uv add toolbox-core
52+
uv add google-adk[toolbox]
5353
```
5454

5555
## Step 3: Configure Google Cloud Authentication
@@ -95,22 +95,23 @@ authentication token.
9595
```python
9696
from google.adk import Agent
9797
from google.adk.apps import App
98-
from toolbox_core import ToolboxSyncClient, auth_methods
98+
from google.adk.tools.toolbox_toolset import ToolboxToolset
99+
from toolbox_adk import CredentialStrategy
99100
100101
# TODO(developer): Replace with your Toolbox Cloud Run Service URL
101102
TOOLBOX_URL = "https://your-toolbox-service-xyz.a.run.app"
102103
103-
# Initialize the client with the Cloud Run URL and Auth headers
104-
client = ToolboxSyncClient(
105-
TOOLBOX_URL,
106-
client_headers={"Authorization": auth_methods.get_google_id_token(TOOLBOX_URL)}
104+
# Initialize the toolset with Workload Identity (generates ID token for the URL)
105+
toolset = ToolboxToolset(
106+
server_url=TOOLBOX_URL,
107+
credentials=CredentialStrategy.workload_identity(target_audience=TOOLBOX_URL)
107108
)
108109
109110
root_agent = Agent(
110111
name='root_agent',
111112
model='gemini-2.5-flash',
112113
instruction="You are a helpful AI assistant designed to provide accurate and useful information.",
113-
tools=client.load_toolset(),
114+
tools=[toolset],
114115
)
115116
116117
app = App(root_agent=root_agent, name="my_agent")

docs/en/samples/bigquery/local_quickstart.md

Lines changed: 43 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ pip install toolbox-llamaindex
335335
{{< /tab >}}
336336
{{< tab header="ADK" lang="bash" >}}
337337
338-
pip install google-adk
338+
pip install google-adk[toolbox]
339339
{{< /tab >}}
340340
341341
{{< /tabpane >}}
@@ -375,7 +375,7 @@ pip install llama-index-llms-google-genai
375375
376376
{{< /tab >}}
377377
{{< tab header="ADK" lang="bash" >}}
378-
pip install toolbox-core
378+
# No other dependencies required for ADK
379379
{{< /tab >}}
380380
{{< /tabpane >}}
381381
@@ -617,8 +617,8 @@ from google.adk.agents import Agent
617617
from google.adk.runners import Runner
618618
from google.adk.sessions import InMemorySessionService
619619
from google.adk.artifacts.in_memory_artifact_service import InMemoryArtifactService
620+
from google.adk.tools.toolbox_toolset import ToolboxToolset
620621
from google.genai import types # For constructing message content
621-
from toolbox_core import ToolboxSyncClient
622622
623623
import os
624624
os.environ['GOOGLE_GENAI_USE_VERTEXAI'] = 'True'
@@ -633,48 +633,47 @@ os.environ['GOOGLE_CLOUD_LOCATION'] = 'us-central1'
633633
634634
# --- Load Tools from Toolbox ---
635635
636-
# TODO(developer): Ensure the Toolbox server is running at <http://127.0.0.1:5000>
637-
638-
with ToolboxSyncClient("<http://127.0.0.1:5000>") as toolbox_client:
639-
# TODO(developer): Replace "my-toolset" with the actual ID of your toolset as configured in your MCP Toolbox server.
640-
agent_toolset = toolbox_client.load_toolset("my-toolset")
641-
642-
# --- Define the Agent's Prompt ---
643-
prompt = """
644-
You're a helpful hotel assistant. You handle hotel searching, booking and
645-
cancellations. When the user searches for a hotel, mention it's name, id,
646-
location and price tier. Always mention hotel ids while performing any
647-
searches. This is very important for any operations. For any bookings or
648-
cancellations, please provide the appropriate confirmation. Be sure to
649-
update checkin or checkout dates if mentioned by the user.
650-
Don't ask for confirmations from the user.
651-
"""
652-
653-
# --- Configure the Agent ---
654-
655-
root_agent = Agent(
656-
model='gemini-2.0-flash-001',
657-
name='hotel_agent',
658-
description='A helpful AI assistant that can search and book hotels.',
659-
instruction=prompt,
660-
tools=agent_toolset, # Pass the loaded toolset
661-
)
636+
# TODO(developer): Ensure the Toolbox server is running at http://127.0.0.1:5000
637+
toolset = ToolboxToolset(server_url="http://127.0.0.1:5000")
638+
639+
# --- Define the Agent's Prompt ---
640+
prompt = """
641+
You're a helpful hotel assistant. You handle hotel searching, booking and
642+
cancellations. When the user searches for a hotel, mention it's name, id,
643+
location and price tier. Always mention hotel ids while performing any
644+
searches. This is very important for any operations. For any bookings or
645+
cancellations, please provide the appropriate confirmation. Be sure to
646+
update checkin or checkout dates if mentioned by the user.
647+
Don't ask for confirmations from the user.
648+
"""
662649
663-
# --- Initialize Services for Running the Agent ---
664-
session_service = InMemorySessionService()
665-
artifacts_service = InMemoryArtifactService()
650+
# --- Configure the Agent ---
651+
652+
root_agent = Agent(
653+
model='gemini-2.0-flash-001',
654+
name='hotel_agent',
655+
description='A helpful AI assistant that can search and book hotels.',
656+
instruction=prompt,
657+
tools=[toolset], # Pass the loaded toolset
658+
)
659+
660+
# --- Initialize Services for Running the Agent ---
661+
session_service = InMemorySessionService()
662+
artifacts_service = InMemoryArtifactService()
663+
664+
runner = Runner(
665+
app_name='hotel_agent',
666+
agent=root_agent,
667+
artifact_service=artifacts_service,
668+
session_service=session_service,
669+
)
670+
671+
async def main():
666672
# Create a new session for the interaction.
667-
session = session_service.create_session(
673+
session = await session_service.create_session(
668674
state={}, app_name='hotel_agent', user_id='123'
669675
)
670676
671-
runner = Runner(
672-
app_name='hotel_agent',
673-
agent=root_agent,
674-
artifact_service=artifacts_service,
675-
session_service=session_service,
676-
)
677-
678677
# --- Define Queries and Run the Agent ---
679678
queries = [
680679
"Find hotels in Basel with Basel in it's name.",
@@ -697,6 +696,10 @@ with ToolboxSyncClient("<http://127.0.0.1:5000>") as toolbox_client:
697696
698697
for text in responses:
699698
print(text)
699+
700+
import asyncio
701+
if __name__ == "__main__":
702+
asyncio.run(main())
700703
{{< /tab >}}
701704
{{< /tabpane >}}
702705

0 commit comments

Comments
 (0)