Skip to content

Commit 8933477

Browse files
authored
Merge branch 'main' into feat/container
2 parents c0cf358 + e12b0af commit 8933477

File tree

62 files changed

+8065
-4827
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+8065
-4827
lines changed

contributing/samples/live_bidi_streaming_multi_agent/agent.py

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,10 @@ def roll_die(sides: int) -> int:
3030
roll_agent = Agent(
3131
name="roll_agent",
3232
model=Gemini(
33-
# see https://docs.cloud.google.com/vertex-ai/generative-ai/docs/migrate
34-
# for vertex model names
35-
model="gemini-live-2.5-flash-native-audio", # vertex
36-
# see https://ai.google.dev/gemini-api/docs/models for AIS model names
37-
# model='gemini-2.5-flash-native-audio-latest', # for AI studio
33+
# Find supported models in Vertex here: https://docs.cloud.google.com/vertex-ai/generative-ai/docs/live-api
34+
model="gemini-live-2.5-flash-native-audio", # Vertex
35+
# Find supported models in Gemini API here: https://ai.google.dev/gemini-api/docs/models
36+
# model='gemini-2.5-flash-native-audio-preview-12-2025', # Gemini API
3837
speech_config=types.SpeechConfig(
3938
voice_config=types.VoiceConfig(
4039
prebuilt_voice_config=types.PrebuiltVoiceConfig(
@@ -85,11 +84,10 @@ def check_prime(nums: list[int]) -> str:
8584
prime_agent = Agent(
8685
name="prime_agent",
8786
model=Gemini(
88-
# see https://docs.cloud.google.com/vertex-ai/generative-ai/docs/migrate
89-
# for vertex model names
90-
model="gemini-live-2.5-flash-native-audio", # vertex
91-
# see https://ai.google.dev/gemini-api/docs/models for AIS model names
92-
# model='gemini-2.5-flash-native-audio-latest', # for AI studio
87+
# Find supported models in Vertex here: https://docs.cloud.google.com/vertex-ai/generative-ai/docs/live-api
88+
model="gemini-live-2.5-flash-native-audio", # Vertex
89+
# Find supported models in Gemini API here: https://ai.google.dev/gemini-api/docs/models
90+
# model='gemini-2.5-flash-native-audio-preview-12-2025', # Gemini API
9391
speech_config=types.SpeechConfig(
9492
voice_config=types.VoiceConfig(
9593
prebuilt_voice_config=types.PrebuiltVoiceConfig(
@@ -128,13 +126,11 @@ def get_current_weather(location: str):
128126

129127

130128
root_agent = Agent(
131-
# find supported models here: https://google.github.io/adk-docs/get-started/streaming/quickstart-streaming/
132129
model=Gemini(
133-
# see https://docs.cloud.google.com/vertex-ai/generative-ai/docs/migrate
134-
# for vertex model names
135-
model="gemini-live-2.5-flash-native-audio", # vertex
136-
# see https://ai.google.dev/gemini-api/docs/models for AIS model names
137-
# model='gemini-2.5-flash-native-audio-latest', # for AI studio
130+
# Find supported models in Vertex here: https://docs.cloud.google.com/vertex-ai/generative-ai/docs/live-api
131+
model="gemini-live-2.5-flash-native-audio", # Vertex
132+
# Find supported models in Gemini API here: https://ai.google.dev/gemini-api/docs/models
133+
# model='gemini-2.5-flash-native-audio-preview-12-2025', # Gemini API
138134
speech_config=types.SpeechConfig(
139135
voice_config=types.VoiceConfig(
140136
prebuilt_voice_config=types.PrebuiltVoiceConfig(

contributing/samples/live_bidi_streaming_parallel_tools_agent/agent.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ def turn_on_tv():
2929

3030

3131
root_agent = Agent(
32-
model="gemini-live-2.5-flash-native-audio",
32+
# Find supported models in Vertex here: https://docs.cloud.google.com/vertex-ai/generative-ai/docs/live-api
33+
model="gemini-live-2.5-flash-native-audio", # Vertex
34+
# Find supported models in Gemini API here: https://ai.google.dev/gemini-api/docs/models
35+
# model='gemini-2.5-flash-native-audio-preview-12-2025', # Gemini API
3336
name="Home_helper",
3437
instruction="Be polite and answer all user's questions.",
3538
tools=[turn_on_lights, turn_on_tv],

contributing/samples/live_bidi_streaming_single_agent/agent.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,10 @@ async def check_prime(nums: list[int]) -> str:
6565

6666

6767
root_agent = Agent(
68-
# see https://docs.cloud.google.com/vertex-ai/generative-ai/docs/migrate
69-
# for vertex model names
70-
model='gemini-live-2.5-flash-native-audio', # vertex
71-
# see https://ai.google.dev/gemini-api/docs/models for AIS model names
72-
# model='gemini-2.5-flash-native-audio-latest', # for AI studio
68+
# Find supported models in Vertex here: https://docs.cloud.google.com/vertex-ai/generative-ai/docs/live-api
69+
model='gemini-live-2.5-flash-native-audio', # Vertex
70+
# Find supported models in Gemini API here: https://ai.google.dev/gemini-api/docs/models
71+
# model='gemini-2.5-flash-native-audio-preview-12-2025', # Gemini API
7372
name='roll_dice_agent',
7473
description=(
7574
'hello world agent that can roll a dice of 6 sides and check prime'

contributing/samples/live_bidi_streaming_tools_agent/agent.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,10 @@ def stop_streaming(function_name: str):
124124

125125

126126
root_agent = Agent(
127-
# see https://docs.cloud.google.com/vertex-ai/generative-ai/docs/migrate
128-
# for vertex model names
129-
model="gemini-live-2.5-flash-native-audio", # vertex
130-
# see https://ai.google.dev/gemini-api/docs/models for AIS model names
131-
# model='gemini-2.5-flash-native-audio-latest', # for AI studio
127+
# Find supported models in Vertex here: https://docs.cloud.google.com/vertex-ai/generative-ai/docs/live-api
128+
model="gemini-live-2.5-flash-native-audio", # Vertex
129+
# Find supported models in Gemini API here: https://ai.google.dev/gemini-api/docs/models
130+
# model='gemini-2.5-flash-native-audio-preview-12-2025', # Gemini API
132131
name="video_streaming_agent",
133132
instruction="""
134133
You are a monitoring agent. You can do video monitoring and stock price monitoring

contributing/samples/live_tool_callbacks_agent/agent.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,9 +217,10 @@ async def after_tool_async_callback(
217217

218218
# Create the agent with tool callbacks
219219
root_agent = Agent(
220-
# find supported models here: https://google.github.io/adk-docs/get-started/streaming/quickstart-streaming/
221-
model="gemini-2.0-flash-live-preview-04-09", # for Vertex project
222-
# model="gemini-live-2.5-flash-preview", # for AI studio key
220+
# Find supported models in Vertex here: https://docs.cloud.google.com/vertex-ai/generative-ai/docs/live-api
221+
model="gemini-live-2.5-flash-native-audio", # Vertex
222+
# Find supported models in Gemini API here: https://ai.google.dev/gemini-api/docs/models
223+
# model='gemini-2.5-flash-native-audio-preview-12-2025', # Gemini API
223224
name="tool_callbacks_agent",
224225
description=(
225226
"Live streaming agent that demonstrates tool callbacks functionality. "
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Copyright 2025 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
from . import agent
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# Copyright 2025 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
"""Sample agent using Vertex AI Agent Engine Sandbox for computer use.
16+
17+
This sample demonstrates how to use the AgentEngineSandboxComputer with ADK
18+
to create a computer use agent that operates in a remote sandbox environment.
19+
20+
Prerequisites:
21+
1. A GCP project with Agent Engine setup (https://docs.cloud.google.com/agent-builder/agent-engine/set-up)
22+
2. A service account with roles/iam.serviceAccountTokenCreator permission
23+
3. Environment variables in contributing/samples/.env:
24+
- GOOGLE_CLOUD_PROJECT: Your GCP project ID
25+
- VMAAS_SERVICE_ACCOUNT: Your service account email
26+
- VMAAS_SANDBOX_NAME: (Optional) Existing sandbox resource name for BYOS mode
27+
28+
Usage:
29+
# Run via ADK web UI
30+
adk web contributing/samples/sandbox_computer_use
31+
32+
# Run via main.py
33+
cd contributing/samples
34+
python -m sandbox_computer_use.main
35+
"""
36+
37+
import os
38+
39+
from dotenv import load_dotenv
40+
from google.adk import Agent
41+
from google.adk.integrations.vmaas import AgentEngineSandboxComputer
42+
from google.adk.tools.computer_use.computer_use_toolset import ComputerUseToolset
43+
44+
# Load environment variables from .env file
45+
load_dotenv(override=True)
46+
47+
# Configuration from environment variables
48+
PROJECT_ID = os.environ.get("GOOGLE_CLOUD_PROJECT")
49+
SERVICE_ACCOUNT = os.environ.get("VMAAS_SERVICE_ACCOUNT")
50+
51+
# Optional: Use existing sandbox (BYOS mode)
52+
# Format: projects/{project}/locations/{location}/reasoningEngines/{id}/sandboxEnvironments/{id}
53+
SANDBOX_NAME = os.environ.get("SANDBOX_NAME") or os.environ.get(
54+
"VMAAS_SANDBOX_NAME"
55+
)
56+
57+
# Create the sandbox computer
58+
sandbox_computer = AgentEngineSandboxComputer(
59+
project_id=PROJECT_ID,
60+
service_account_email=SERVICE_ACCOUNT,
61+
sandbox_name=SANDBOX_NAME,
62+
search_engine_url="https://www.google.com",
63+
)
64+
65+
# Create agent with the computer use toolset
66+
root_agent = Agent(
67+
model="gemini-2.5-computer-use-preview-10-2025",
68+
name="sandbox_computer_use_agent",
69+
description=(
70+
"A computer use agent that operates a browser in a remote Vertex AI"
71+
" sandbox environment to complete user tasks."
72+
),
73+
instruction="""You are a computer use agent that can operate a web browser
74+
to help users complete tasks. You have access to browser controls including:
75+
- Navigation (go to URLs, back, forward, search)
76+
- Mouse actions (click, hover, scroll, drag and drop)
77+
- Keyboard input (type text, key combinations)
78+
- Screenshots (to see the current state)
79+
80+
When given a task:
81+
1. Think about what steps are needed to accomplish it
82+
2. Take actions one at a time, observing the results
83+
3. If something doesn't work, try alternative approaches
84+
4. Report back when the task is complete or if you encounter issues
85+
86+
Be careful with sensitive information and always respect website terms of service.
87+
""",
88+
tools=[ComputerUseToolset(computer=sandbox_computer)],
89+
)
Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
# Copyright 2025 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
"""Main script to run the sandbox computer use agent.
16+
17+
This script demonstrates how to run the sandbox computer use agent
18+
programmatically using the InMemoryRunner.
19+
20+
Prerequisites:
21+
1. Set environment variables:
22+
- GOOGLE_CLOUD_PROJECT: Your GCP project ID
23+
- VMAAS_SERVICE_ACCOUNT: Your service account email with
24+
roles/iam.serviceAccountTokenCreator permission
25+
26+
Usage:
27+
cd contributing/samples
28+
python -m sandbox_computer_use.main
29+
"""
30+
31+
import asyncio
32+
import os
33+
import time
34+
35+
from dotenv import load_dotenv
36+
from google.adk.cli.utils import logs
37+
from google.adk.runners import InMemoryRunner
38+
from google.adk.sessions.session import Session
39+
from google.genai import types
40+
41+
# Import the agent module
42+
from . import agent
43+
44+
load_dotenv(override=True)
45+
logs.log_to_tmp_folder()
46+
47+
48+
async def run_prompt(
49+
runner: InMemoryRunner,
50+
session: Session,
51+
user_id: str,
52+
message: str,
53+
) -> None:
54+
"""Run a single prompt and print the response.
55+
56+
Args:
57+
runner: The agent runner.
58+
session: The session to use.
59+
user_id: The user ID.
60+
message: The user message.
61+
"""
62+
content = types.Content(
63+
role="user", parts=[types.Part.from_text(text=message)]
64+
)
65+
print(f"\n** User says: {message}")
66+
print("-" * 40)
67+
68+
async for event in runner.run_async(
69+
user_id=user_id,
70+
session_id=session.id,
71+
new_message=content,
72+
):
73+
if event.content and event.content.parts:
74+
for part in event.content.parts:
75+
if part.text:
76+
print(f"** {event.author}: {part.text}")
77+
elif hasattr(part, "inline_data") and part.inline_data:
78+
# Screenshot received
79+
print(f"** {event.author}: [Screenshot received]")
80+
81+
82+
async def main():
83+
"""Main function to run the sandbox computer use agent."""
84+
# Validate environment
85+
project_id = os.environ.get("GOOGLE_CLOUD_PROJECT")
86+
service_account = os.environ.get("VMAAS_SERVICE_ACCOUNT")
87+
88+
if not project_id:
89+
print("ERROR: GOOGLE_CLOUD_PROJECT environment variable is not set.")
90+
print("Please set it to your GCP project ID.")
91+
return
92+
93+
if not service_account:
94+
print("ERROR: VMAAS_SERVICE_ACCOUNT environment variable is not set.")
95+
print(
96+
"Please set it to your service account email with"
97+
" roles/iam.serviceAccountTokenCreator permission."
98+
)
99+
return
100+
101+
print("=" * 60)
102+
print("Sandbox Computer Use Agent Demo")
103+
print("=" * 60)
104+
print(f"Project: {project_id}")
105+
print(f"Service Account: {service_account}")
106+
print("=" * 60)
107+
108+
app_name = "sandbox_computer_use_demo"
109+
user_id = "demo_user"
110+
111+
# Create runner and session
112+
runner = InMemoryRunner(
113+
agent=agent.root_agent,
114+
app_name=app_name,
115+
)
116+
session = await runner.session_service.create_session(
117+
app_name=app_name, user_id=user_id
118+
)
119+
120+
print(f"\nSession created: {session.id}")
121+
print("\nStarting agent interaction...")
122+
123+
start_time = time.time()
124+
125+
# Example interaction: Navigate and describe
126+
await run_prompt(
127+
runner,
128+
session,
129+
user_id,
130+
"Navigate to https://www.google.com and tell me what you see.",
131+
)
132+
133+
# Example interaction: Search for something
134+
await run_prompt(
135+
runner,
136+
session,
137+
user_id,
138+
"Search for 'Vertex AI Agent Engine' and tell me the first result.",
139+
)
140+
141+
end_time = time.time()
142+
143+
print("\n" + "=" * 60)
144+
print(f"Demo completed in {end_time - start_time:.2f} seconds")
145+
print("=" * 60)
146+
147+
# Print session state to show sandbox info
148+
session = await runner.session_service.get_session(
149+
app_name=app_name, user_id=user_id, session_id=session.id
150+
)
151+
print("\nSession state (sandbox info):")
152+
for key, value in session.state.items():
153+
if key.startswith("_vmaas_"):
154+
# Mask token for security
155+
if "token" in key.lower():
156+
print(f" {key}: [REDACTED]")
157+
else:
158+
print(f" {key}: {value}")
159+
160+
161+
if __name__ == "__main__":
162+
asyncio.run(main())

contributing/samples/toolbox_agent/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ Before starting, ensure you have Python installed on your system.
1515
Run the following command to download and install the MCP Toolbox binary.
1616

1717
> [!NOTE]
18-
> You can find the latest version on the [Releases page](https://github.com/googleapis/genai-toolbox/releases) and update the version in the URL below.
18+
> You can find the latest version on the [Releases page](https://github.com/googleapis/mcp-toolbox/releases) and update the version in the URL below.
1919
2020
```bash
2121
export OS="linux/amd64" # one of linux/amd64, darwin/arm64, darwin/amd64, or windows/amd64
22-
curl -O https://storage.googleapis.com/genai-toolbox/v0.31.0/$OS/toolbox
22+
curl -O https://storage.googleapis.com/mcp-toolbox-for-databases/v1.1.0/$OS/toolbox
2323
chmod +x toolbox
2424
```
2525

0 commit comments

Comments
 (0)