Lab L2.3: Skills System

🎯 Assignment: Accept this lab on GitHub Classroom
You’ll get your own repository with starter code, instructions, and automatic grading.

   
Duration 60 minutes
Prerequisites Previous module completed

Objectives

  • Add built-in skills to agents
  • Configure skill parameters
  • Combine multiple skills

How to Complete This Lab

  1. Accept the Assignment — Click the GitHub Classroom link above
  2. Clone Your Repogit clone <your-repo-url>
  3. Read the README — Your repo has detailed requirements and grading criteria
  4. Write Your Code — Implement the solution in solution/agent.py
  5. Test Locally — Use swaig-test to verify your agent works
  6. Push to Submitgit push triggers auto-grading

Key Concepts

The following exercises walk through the concepts you’ll need. Your GitHub Classroom repo README has the specific requirements for grading.

Part 1: DateTime Skill (15 min)

Task

Create an agent with the datetime skill for time-related queries.

Starter Code

#!/usr/bin/env python3
"""Lab 2.3: Skills system."""

from signalwire_agents import AgentBase


class SkillsAgent(AgentBase):
    def __init__(self):
        super().__init__(name="skills-agent")

        self.prompt_add_section(
            "Role",
            "You are a helpful assistant with access to various skills. "
            "Use your skills to help users with time, math, and web information."
        )

        self.add_language("English", "en-US", "rime.spore")

        # TODO: Add skills


if __name__ == "__main__":
    agent = SkillsAgent()
    agent.run()

Your Task

Add the datetime skill with timezone configuration.

Expected Result

# Add datetime skill with timezone
self.add_skill(
    "datetime",
    {
        "timezone": "America/New_York",
        "format": "12-hour"
    }
)

Part 2: Math Skill (10 min)

Task

Add the math skill for calculations.

Your Task

Add the math skill (no special configuration needed).

Expected Result

# Add math skill
self.add_skill("math")

Part 3: Web Search Skill (20 min)

Task

Add the web search skill for information retrieval.

Your Task

Add the web_search skill. Note: This requires API credentials in production.

Expected Result

# Add web search skill
self.add_skill(
    "web_search",
    {
        "max_results": 3
    }
)

Testing

# Test the agent
swaig-test lab2_3_skills.py --dump-swml

# List all tools (should include skill functions)
swaig-test lab2_3_skills.py --list-tools

# Verify skills are in SWML
swaig-test lab2_3_skills.py --dump-swml | grep -A5 "includes"

Validation Checklist

  • DateTime skill is registered
  • Math skill is registered
  • Web search skill is registered
  • Skills appear in SWML includes section
  • Skill configurations are applied

Testing Conversation Flow

Run the agent and test with these prompts:

  1. “What time is it?”
  2. “What’s 15% of 85?”
  3. “Search for the weather in New York”

Challenge Extension

Create an agent with multiple datetime skills for different timezones:

# Multiple timezone support
self.add_skill(
    "datetime",
    {
        "timezone": "America/New_York",
        "format": "12-hour"
    },
    tool_name="get_eastern_time"
)

self.add_skill(
    "datetime",
    {
        "timezone": "America/Los_Angeles",
        "format": "12-hour"
    },
    tool_name="get_pacific_time"
)

Submission

Upload your completed lab2_3_skills.py file.


Complete Agent Code

Click to reveal complete solution
#!/usr/bin/env python3
"""Skills system agent with built-in skills.

Lab 2.3 Deliverable: Demonstrates adding built-in skills (datetime, math)
with configuration options.
"""

from signalwire_agents import AgentBase


class SkillsAgent(AgentBase):
    """Agent with built-in skills for various capabilities."""

    def __init__(self):
        super().__init__(name="skills-agent")

        self.prompt_add_section(
            "Role",
            "You are a helpful assistant with access to various skills. "
            "Use your skills to help users with time and math calculations."
        )

        self.prompt_add_section(
            "Capabilities",
            bullets=[
                "Tell the current date and time in various timezones",
                "Perform mathematical calculations"
            ]
        )

        self.add_language("English", "en-US", "rime.spore")

        # Add built-in skills
        self._setup_skills()

    def _setup_skills(self):
        """Configure built-in skills."""

        # DateTime skill with timezone configuration
        self.add_skill(
            "datetime",
            {
                "timezone": "America/New_York",
                "format": "12-hour"
            }
        )

        # Math skill (no special configuration needed)
        self.add_skill("math")


class MultiTimezoneAgent(AgentBase):
    """Challenge extension: Agent that handles multiple timezone queries.

    Note: The datetime skill provides a single get_datetime function.
    To handle multiple timezones, we configure a default timezone and
    provide instructions for the AI to handle timezone conversion requests.
    """

    def __init__(self):
        super().__init__(name="multi-timezone-agent")

        self.prompt_add_section(
            "Role",
            "You help users check time in different timezones."
        )

        self.prompt_add_section(
            "Timezone Information",
            bullets=[
                "Eastern Time (ET): America/New_York",
                "Pacific Time (PT): America/Los_Angeles",
                "London (GMT/BST): Europe/London",
                "Tokyo (JST): Asia/Tokyo",
                "When users ask for time in a specific timezone, use the datetime skill and mention the timezone"
            ]
        )

        self.add_language("English", "en-US", "rime.spore")

        # Single datetime skill - the AI handles timezone context
        self.add_skill(
            "datetime",
            {
                "timezone": "America/New_York",
                "format": "12-hour"
            }
        )


if __name__ == "__main__":
    agent = SkillsAgent()
    agent.run()

Back to top

SignalWire AI Agents Certification Program