Skip to content

Commit 8da7d9b

Browse files
danishiclaude
andauthored
feat: implement ADK Skills reference with SkillToolset (#10)
* feat: implement ADK Skills reference with SkillToolset integration Add greeting-skill and datetime-skill as file-based ADK Skills, and integrate them via SkillToolset replacing direct tool registration. https://claude.ai/code/session_01N83Pfw2mYT8viyitEB8d92 * docs: add skills directory to README project structure https://claude.ai/code/session_01N83Pfw2mYT8viyitEB8d92 --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent b05b90a commit 8da7d9b

6 files changed

Lines changed: 74 additions & 1 deletion

File tree

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,15 @@ app/
2626
comedian.py # ex: Comedian agent implementation
2727
tools/
2828
get_current_datetime.py # ex: Date/time utility tool
29+
skills/
30+
greeting-skill/ # ex: Greeting skill (file-based ADK Skill)
31+
SKILL.md
32+
references/
33+
greeting_templates.md
34+
datetime-skill/ # ex: Datetime skill (file-based ADK Skill)
35+
SKILL.md
36+
references/
37+
default_timezones.md
2938
scripts/
3039
deploy.sh # Helper script to deploy to Cloud Run
3140
Dockerfile # Container definition for Cloud Run

app/main.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import os
22
import json
3+
import pathlib
34
import re
45
import uuid
56
from typing import List
@@ -14,6 +15,8 @@
1415
from google.adk.agents import Agent
1516
from google.adk.events.event import Event
1617
from google.adk.runners import InMemoryRunner
18+
from google.adk.skills import load_skill_from_dir
19+
from google.adk.tools.skill_toolset import SkillToolset
1720
# from google.adk.tools import google_search
1821

1922
from .agents.comedian import comedian_agent
@@ -144,6 +147,16 @@ async def _populate_session_from_thread(
144147
await session_service.append_event(session=session, event=event_obj)
145148

146149

150+
# Load skills from directory
151+
_skills_dir = pathlib.Path(__file__).parent / "skills"
152+
greeting_skill = load_skill_from_dir(_skills_dir / "greeting-skill")
153+
datetime_skill = load_skill_from_dir(_skills_dir / "datetime-skill")
154+
155+
skill_toolset = SkillToolset(
156+
skills=[greeting_skill, datetime_skill],
157+
additional_tools=[get_current_datetime],
158+
)
159+
147160
root_agent = Agent(
148161
name="slack_bot_agent",
149162
model=MODEL_NAME,
@@ -168,7 +181,7 @@ async def _populate_session_from_thread(
168181
169182
Always structure your response clearly, using these rules so it renders correctly in Slack.""",
170183
tools=[
171-
get_current_datetime,
184+
skill_toolset,
172185
],
173186
sub_agents=[
174187
comedian_agent,

app/skills/datetime-skill/SKILL.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
name: datetime-skill
3+
description: A skill that provides current date and time information for any timezone using the get_current_datetime tool.
4+
metadata:
5+
adk_additional_tools:
6+
- get_current_datetime
7+
---
8+
9+
Step 1: Identify the timezone the user is asking about. If no timezone is specified, check 'references/default_timezones.md' for common defaults.
10+
Step 2: Use the `get_current_datetime` tool with the appropriate timezone identifier (e.g., "Asia/Tokyo", "America/New_York").
11+
Step 3: Format the result clearly for the user, including the timezone name and the current date/time.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Default Timezone Reference
2+
3+
## Common Timezone Mappings
4+
- Japan / Tokyo: Asia/Tokyo
5+
- US East / New York: America/New_York
6+
- US West / Los Angeles / San Francisco: America/Los_Angeles
7+
- US Central / Chicago: America/Chicago
8+
- UK / London: Europe/London
9+
- Central Europe / Paris / Berlin: Europe/Paris
10+
- India / Mumbai: Asia/Kolkata
11+
- China / Beijing / Shanghai: Asia/Shanghai
12+
- Australia / Sydney: Australia/Sydney
13+
- Brazil / São Paulo: America/Sao_Paulo
14+
15+
## Default Behavior
16+
If the user does not specify a timezone, default to "Asia/Tokyo" as the primary user base is in Japan.

app/skills/greeting-skill/SKILL.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
name: greeting-skill
3+
description: A friendly greeting skill that welcomes users and provides helpful onboarding information about the Slack bot.
4+
---
5+
6+
Step 1: Read the 'references/greeting_templates.md' file to understand available greeting styles.
7+
Step 2: Identify the user's name from the `[Speaker: <name>]` tag in the message.
8+
Step 3: Return a warm, personalized greeting based on the reference, using the user's name.
9+
Step 4: Briefly mention key capabilities the bot offers (humor via comedian, current datetime lookup).
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Greeting Templates
2+
3+
## Standard Greeting
4+
Hello, {name}! I'm your Slack Bot assistant. How can I help you today?
5+
6+
## Capabilities Introduction
7+
Here's what I can do:
8+
- Answer questions and have conversations
9+
- Tell jokes and bring humor (via the comedian skill)
10+
- Look up the current date and time in any timezone
11+
12+
## Tips
13+
- Mention me in a thread to continue a conversation
14+
- Ask me to be funny if you want a laugh
15+
- Ask me what time it is in any city or timezone

0 commit comments

Comments
 (0)