Lab 39.5: Loading and Using Agent Skills
Goalโ
In this lab, you will create a simple ADK Skill on your file system and configure an agent to use it via the SkillToolset.
Step 1: Create the Projectโ
-
Create a new agent project inside your
adk-training/workspace:Environment setup:
- 1-Click Launch (Browser): Open in GitHub CodespacesOpen in Google Cloud Shell
- Local machine: If you're continuing the course in sequence,
cdinto theadk-trainingproject you created in Module 2 and skip the block below -- your environment and dependencies already carry forward. If you're starting fresh at this module, create that project first:uv init adk-training --python 3.10 && cd adk-training
uv add "google-adk>=2.1.0" python-dotenv - DevContainer / Codespaces (Alternative): If you opened this repository in a DevContainer or GitHub Codespaces, Python 3.11,
uv,gcloud, and all core ADK dependencies are pre-installed in your container environment.
uv run adk create skills_agentThis prompts for a model choice (any option is fine, you'll set the real model in
agent.pybelow) and, if needed, a backend -- there's no separate "type" prompt,agent.py/Code is already the default. -
Navigate to the directory:
cd skills_agent
Step 2: Create the Skill Directoryโ
We need to create the physical structure for our skill.
- Inside
skills_agent, create theskills/greeting-skilldirectory and requiredSKILL.mdfile:mkdir -p skills/greeting-skill
touch skills/greeting-skill/SKILL.md
Step 3: Write the Skill Instructionsโ
Open skills/greeting-skill/SKILL.md in your editor and paste the following content. This defines the metadata (how the agent knows when to use it) and the body (the actual instructions).
---
name: greeting-skill
description: The official Nebula-9 Collective greeting protocol. Use this skill any time the user greets you, says hello, or asks to be greeted.
---
# Nebula-9 Collective Greeting Protocol
You are now using the official Nebula-9 Collective Greeting Skill!
Step 1: Read the user's input to see if they provided a name.
Step 2: Respond using EXACTLY this template, replacing [NAME] with their name (or "traveler" if you don't know it):
"๐ Greetings, [NAME]! Welcome aboard the Nebula-9 Collective. May your orbit be ever bright. ๐โจ"
Step 3: Do not deviate from this template under any circumstances -- no extra commentary before or after it.
This gives the skill a distinctive, made-up phrase ("Nebula-9 Collective") that a model could never produce on its own -- so if you see it in the final response, that's proof the skill actually loaded and was followed, not just the model being generically friendly.
Step 4: Configure the Agentโ
Exercise: Open skills_agent/agent.py. Your task is to load the skill from the directory and provide it to the agent.
import pathlib
from google.adk.agents import Agent
from google.adk.skills import load_skill_from_dir
from google.adk.tools.skill_toolset import SkillToolset
from google.adk.code_executors.unsafe_local_code_executor import UnsafeLocalCodeExecutor
# TODO: 1. Load the skill from the directory you created.
# Hint: Use pathlib.Path(__file__).parent / "skills" / "greeting-skill"
greeting_skill = None
# TODO: 2. Create the SkillToolset.
# Pass your loaded skill in a list to the `skills` parameter.
# We must include the code_executor even if we don't have scripts yet.
my_skill_toolset = None
# TODO: 3. Configure the Agent.
# Add your `my_skill_toolset` to the agent's `tools` list.
# Also add an `instruction` that names the skill explicitly and tells the
# agent it MUST call `load_skill('greeting-skill')` whenever the user
# greets it. A generic "check your skills if relevant" instruction is too
# weak in practice -- the model won't reliably invoke a skill for a message
# as simple as "hi" unless the skill and the trigger condition are named
# directly.
root_agent = Agent(
model="gemini-3.8-flash",
name="skill_user_agent",
description="An agent that can use specialized skills.",
# Add instruction and tools here
)
(Note: The full implementation is available in the lab-solution.md or in the Reference Solution Vault below if you need a hint.)
Step 5: Test the Skillโ
- Set up your
.envfile insideskills_agent/. - Navigate back to the parent
adk-training/directory (cd ..) and launch the Dev UI:Selectcd ..
uv run adk webskills_agentfrom the agent dropdown in the Dev UI. - Interact with the system:
- Say "Hello there, my name is Alex."
- You should receive the exact Nebula-9 Collective greeting template, including the made-up "Nebula-9 Collective" phrase -- proof the agent loaded and followed the
SKILL.mdinstructions, not just a generic friendly reply.
- Examine the Trace View:
- Look at the trace. You should see the agent making a
load_skilltool call to activategreeting-skill. This is progressive disclosure in action!
- Look at the trace. You should see the agent making a
Self-Reflection Questionsโ
- Look at your
SKILL.mdfile. Which part of it is loaded into the agent's context before the user says hello? Which part is loaded after? - Why do we have to wrap the skill in a
SkillToolsetbefore giving it to the agent? (Think about the other things a toolset might manage, like code executors or additional tools). - Your
instructionnamesgreeting-skilland its trigger condition explicitly. What do you think would happen if you had 20 skills instead of 1 -- would naming every single one in the instruction still scale, and what does that suggest about thesearch_skills/Skill Registry pattern mentioned in "Going Further"?
๐ Reference Solution Vaultโ
Official Solution Vault โ Module 39.5
Locked Challenge โ Active Pedagogical Socratic Gate