Agents

SkillBase

View as MarkdownOpen in Claude

SkillBase is the abstract base class for all agent skills. Skills are modular, reusable capabilities — such as weather lookup, web search, or calendar access — that can be added to any AgentBase agent with a single call to agent.add_skill().

Extend SkillBase to create custom skills. The SDK discovers skills automatically from the signalwire/skills/ directory and validates dependencies on load.

For the catalog of built-in skills and their configuration parameters, see the Skills page.

Class Attributes

Define these on your subclass to configure the skill:

SKILL_NAME
strRequired

Unique identifier for the skill (e.g., "weather", "web_search"). Used as the key when calling agent.add_skill().

SKILL_DESCRIPTION
strRequired

Human-readable description of the skill.

SKILL_VERSION
strDefaults to 1.0.0

Semantic version string.

REQUIRED_PACKAGES
list[str]Defaults to []

Python packages the skill needs. Checked on setup with validate_packages().

REQUIRED_ENV_VARS
list[str]Defaults to []

Environment variables the skill needs. Checked on setup with validate_env_vars().

SUPPORTS_MULTIPLE_INSTANCES
boolDefaults to false

When True, the same skill can be added to an agent multiple times with different configurations (distinguished by a tool_name parameter).

Instance Properties

agent
AgentBase

Reference to the parent agent.

params
dict[str, Any]

Configuration parameters (with swaig_fields removed).

logger
Logger

Skill-specific logger namespaced as signalwire.skills.<SKILL_NAME>.

swaig_fields
dict[str, Any]

SWAIG metadata extracted from params, automatically merged into tool definitions when using define_tool().

Methods

Examples

Custom skill

1import os
2from signalwire.core.skill_base import SkillBase
3from signalwire import FunctionResult
4
5class WeatherSkill(SkillBase):
6 SKILL_NAME = "weather"
7 SKILL_DESCRIPTION = "Provides weather information"
8 SKILL_VERSION = "1.0.0"
9 REQUIRED_PACKAGES = ["requests"]
10 REQUIRED_ENV_VARS = ["WEATHER_API_KEY"]
11
12 def setup(self) -> bool:
13 if not self.validate_packages():
14 return False
15 if not self.validate_env_vars():
16 return False
17 self.api_key = os.getenv("WEATHER_API_KEY")
18 return True
19
20 def register_tools(self):
21 self.define_tool(
22 name="get_weather",
23 description="Get current weather for a location",
24 handler=self._get_weather,
25 parameters={
26 "type": "object",
27 "properties": {
28 "location": {
29 "type": "string",
30 "description": "City name or zip code"
31 }
32 },
33 "required": ["location"]
34 }
35 )
36
37 def _get_weather(self, args, raw_data):
38 import requests
39 location = args.get("location")
40 resp = requests.get(
41 f"https://api.weather.com/v1/current?q={location}&key={self.api_key}"
42 )
43 data = resp.json()
44 return FunctionResult(
45 f"Weather in {location}: {data['condition']}, {data['temp']}F"
46 )
47
48 def get_hints(self):
49 return ["weather", "temperature", "forecast"]
50
51 def _get_prompt_sections(self):
52 return [{
53 "title": "Weather Information",
54 "body": "You can check weather for any location."
55 }]
56
57 @classmethod
58 def get_parameter_schema(cls):
59 schema = super().get_parameter_schema()
60 schema.update({
61 "units": {
62 "type": "string",
63 "description": "Temperature units",
64 "default": "fahrenheit",
65 "enum": ["fahrenheit", "celsius"]
66 }
67 })
68 return schema

Using a skill

1from signalwire import AgentBase
2
3agent = AgentBase(name="weather-agent")
4agent.set_prompt_text("You are a helpful assistant.")
5agent.add_skill("weather")
6
7# Or with custom configuration
8agent.add_skill("weather", {"units": "celsius"})
9
10if __name__ == "__main__":
11 agent.run()