Creating Custom Skills
This guide shows how to build a minimal, production-ready skill that is consistent with the SDK, Quickstart, and platform conventions.
What a Skill Provides
@toolfunctions: executable capabilities@promptproducers: guide LLM behavior@hookhandlers: react to lifecycle events (e.g.,on_message)@handoffrules: route to other agents when needed- Optional
@httpendpoints: custom REST handlers mounted under the agent - Declared dependencies: ensure other skills are present (e.g., memory)
Minimal Skill
from webagents import Skill, tool, hook, handoff
class NotesSkill(Skill):
def __init__(self, config=None):
super().__init__(
config=config,
scope="all", # all | owner | admin
dependencies=["memory"], # requires memory for storage
)
@tool
def add_note(self, text: str) -> dict:
"""Add a note to the userās short-term memory."""
# In a real implementation, call memory skill here
return {"status": "saved", "text": text}
@hook("on_message")
async def normalize_message(self, context):
# Lightweight preprocessing for downstream tools or model
return context
@handoff("notes-auditor")
def route_to_auditor(self, text: str) -> bool:
return "audit" in text.lower()
Adding HTTP Endpoints (Optional)
from webagents import http
@http("/notes", method="post", scope="owner")
async def create_note(payload: dict) -> dict:
return {"received": payload, "status": "ok"}
- Endpoints are mounted under your agent path when served
scopecan restrict access toowneroradmin
Use Your Skill in an Agent
from webagents.agents.core.base_agent import BaseAgent
from webagents.agents.skills.core.memory import ShortTermMemorySkill
agent = BaseAgent(
name="notes",
instructions="You help users capture and recall short notes.",
model="openai/gpt-4o-mini",
skills={
"memory": ShortTermMemorySkill(),
"notes": NotesSkill(),
}
)
Serve Your Agent
from webagents.server.core.app import create_server
import uvicorn
server = create_server(agents=[agent])
uvicorn.run(server.app, host="0.0.0.0", port=8000)
Best Practices
- Keep one clear responsibility per skill
- Validate inputs in tools and HTTP handlers
- Use
scopeappropriately (all,owner,admin) - Prefer async for I/O and external API calls
- Leverage dependencies for cross-skill collaboration
Learn More
- Skills Framework: skills/overview.md
- Platform Skills: platform/auth.md, platform/discovery.md, platform/nli.md, platform/payments.md
- Agent Overview: agent/overview.md
- Quickstart: quickstart.md