fix: Add a script to the sample skills agent

Added a get_humidity script to demo the new RunSkillScript tool

Co-authored-by: Kathy Wu <wukathy@google.com>
PiperOrigin-RevId: 875901416
This commit is contained in:
Kathy Wu
2026-02-26 14:49:40 -08:00
committed by Copybara-Service
parent 8a3161202e
commit 8ad8bc9b69
3 changed files with 38 additions and 2 deletions
+7 -1
View File
@@ -17,6 +17,7 @@
import pathlib
from google.adk import Agent
from google.adk.code_executors.unsafe_local_code_executor import UnsafeLocalCodeExecutor
from google.adk.skills import load_skill_from_dir
from google.adk.skills import models
from google.adk.tools.skill_toolset import SkillToolset
@@ -44,7 +45,12 @@ weather_skill = load_skill_from_dir(
pathlib.Path(__file__).parent / "skills" / "weather-skill"
)
my_skill_toolset = SkillToolset(skills=[greeting_skill, weather_skill])
# WARNING: UnsafeLocalCodeExecutor has security concerns and should NOT
# be used in production environments.
my_skill_toolset = SkillToolset(
skills=[greeting_skill, weather_skill],
code_executor=UnsafeLocalCodeExecutor(),
)
root_agent = Agent(
model="gemini-2.5-flash",
@@ -4,4 +4,5 @@ description: A skill that provides weather information based on reference data.
---
Step 1: Check 'references/weather_info.md' for the current weather.
Step 2: Provide the weather update to the user.
Step 2: If humidity is requested, use run 'scripts/get_humidity.py' with the `location` argument.
Step 3: Provide the update to the user.
@@ -0,0 +1,29 @@
# Copyright 2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import argparse
def get_humidity(location: str) -> str:
"""Fetch live humidity for a given location. (Simulated)"""
print(f"Fetching live humidity for {location}...")
return "45% (Simulated)"
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("--location", type=str, default="Mountain View")
args = parser.parse_args()
print(get_humidity(args.location))