| Duration | 2 hours |
| Day | 3 of 5 |
Learning Objectives
By the end of this module, students will be able to:
- Understand the skill architecture
- Add and configure built-in skills
- Compose multiple skills into agents
- Check and manage loaded skills
Topics
1. What Are Skills? (20 min)
Definition
Skills are reusable capability modules that provide:
- Functions (tools the AI can call)
- Prompts (additional instructions)
- Hints (speech recognition improvements)
- Global data (shared information)
Skills vs Functions
| Functions | Skills |
|---|---|
| Single capability | Bundle of capabilities |
| Defined in agent | Packaged separately |
| Agent-specific | Reusable across agents |
| No prompts | Can include prompts |
Built-in Skills
| Skill | Purpose |
|---|---|
datetime | Current date/time info |
math | Mathematical calculations |
web_search | Internet searches |
datasphere | SignalWire knowledge base |
native_vector_search | Local document search |
2. Adding Skills (25 min)
Basic Usage
from signalwire_agents import AgentBase
agent = AgentBase(name="helpful-agent")
# Add a skill
agent.add_skill("datetime")
That’s it! The agent now knows the current date and time.
Skills with Configuration
# Web search with API key
agent.add_skill("web_search", {
"api_key": os.getenv("SEARCH_API_KEY")
})
# Vector search with index path
agent.add_skill("native_vector_search", {
"index_path": "/data/knowledge.swsearch"
})
Multiple Skills
agent.add_skill("datetime")
agent.add_skill("math")
agent.add_skill("web_search", {"api_key": "..."})
Or chain them:
(agent
.add_skill("datetime")
.add_skill("math")
.add_skill("web_search", {"api_key": "..."}))
3. Built-in Skills Deep Dive (30 min)
datetime Skill
Provides current date, time, timezone information.
agent.add_skill("datetime")
Functions Added:
get_current_time- Current time in timezoneget_current_date- Current date
Example Conversation:
Caller: “What time is it?” Agent: “It’s currently 2:30 PM Eastern Time.”
math Skill
Performs mathematical calculations.
agent.add_skill("math")
Functions Added:
calculate- Evaluate math expressions
Example Conversation:
Caller: “What’s 15% of 250?” Agent: “15% of 250 is 37.50.”
web_search Skill
Searches the internet for information.
agent.add_skill("web_search", {
"api_key": os.getenv("TAVILY_API_KEY")
})
Functions Added:
search_web- Search and summarize results
Example Conversation:
Caller: “What’s the latest news about SignalWire?” Agent: “According to recent articles…”
native_vector_search Skill
Searches local document indexes.
agent.add_skill("native_vector_search", {
"index_path": "/data/products.swsearch",
"top_k": 5
})
Functions Added:
search_documents- Semantic search over documents
4. Skill Management (20 min)
Check Loaded Skills
# List all skills
skills = agent.get_skills()
print(skills) # ['datetime', 'math']
# Check if specific skill is loaded
if agent.has_skill("datetime"):
print("DateTime skill is active")
Remove Skills
agent.remove_skill("math")
Skill Priority
Skills added later can override earlier ones:
agent.add_skill("basic_search") # Adds search function
agent.add_skill("advanced_search") # Overrides search function
5. Skill Composition Patterns (25 min)
Support Agent Pattern
class SupportAgent(AgentBase):
def __init__(self):
super().__init__(name="support")
self.prompt_add_section(
"Role",
"You are a technical support agent."
)
# Knowledge skills
self.add_skill("native_vector_search", {
"index_path": "/data/support_docs.swsearch"
})
# Utility skills
self.add_skill("datetime")
# Custom functions for actions
self._add_custom_functions()
Sales Agent Pattern
class SalesAgent(AgentBase):
def __init__(self):
super().__init__(name="sales")
# Product knowledge
self.add_skill("native_vector_search", {
"index_path": "/data/products.swsearch"
})
# Pricing calculations
self.add_skill("math")
# Current promotions (time-sensitive)
self.add_skill("datetime")
Research Agent Pattern
class ResearchAgent(AgentBase):
def __init__(self):
super().__init__(name="research")
# Internal docs
self.add_skill("native_vector_search", {
"index_path": "/data/internal.swsearch"
})
# External research
self.add_skill("web_search", {
"api_key": os.getenv("SEARCH_API_KEY")
})
# Calculations
self.add_skill("math")
Complete Example
Click to reveal complete solution
#!/usr/bin/env python3
"""Multi-skill support agent."""
import os
from signalwire_agents import AgentBase, SwaigFunctionResult
class SmartSupportAgent(AgentBase):
def __init__(self):
super().__init__(name="smart-support")
self._configure_prompts()
self._configure_voice()
self._add_skills()
self._add_custom_functions()
def _configure_prompts(self):
self.prompt_add_section(
"Role",
"You are an intelligent support agent for TechCorp. "
"Use your skills to help customers effectively."
)
self.prompt_add_section(
"Capabilities",
bullets=[
"Search our knowledge base for product information",
"Calculate prices and discounts",
"Tell customers the current date and time",
"Create support tickets for complex issues"
]
)
def _configure_voice(self):
self.add_language("English", "en-US", "rime.spore")
def _add_skills(self):
# Date/time awareness
self.add_skill("datetime")
# Price calculations
self.add_skill("math")
# Knowledge base search
if os.path.exists("/data/support.swsearch"):
self.add_skill("native_vector_search", {
"index_path": "/data/support.swsearch",
"top_k": 3
})
def _add_custom_functions(self):
@self.tool(description="Create a support ticket")
def create_ticket(
issue: str,
priority: str = "normal"
) -> SwaigFunctionResult:
ticket_id = f"TKT-{hash(issue) % 10000:04d}"
return SwaigFunctionResult(
f"Created ticket {ticket_id} with {priority} priority."
)
if __name__ == "__main__":
agent = SmartSupportAgent()
agent.run()
Key Takeaways
- Skills bundle capabilities - Functions, prompts, hints together
- Built-in skills are ready to use - datetime, math, search
- Configuration via parameters - API keys, paths, options
- Compose for power - Multiple skills work together
- Manage what’s loaded - Check, add, remove as needed
Preparation for Lab 2.3
- Review available built-in skills
- Think about what capabilities your agent needs
- Have API keys ready if using web_search
Lab Preview
In Lab 2.3, you will:
- Add datetime and math skills
- Configure web_search skill
- Combine skills with custom functions
- Test skill interactions