Build Your First Agent
In this tutorial, you'll build a simple customer inquiry classifier agent. By the end, you'll understand the core Waxell concepts.
Prerequisites
- Python 3.10+
- Waxell SDK and Runtime installed
pip install waxell-sdk waxell-runtime
Step 1: Define the Agent
Create a new file inquiry_agent.py:
from waxell_sdk import agent, workflow, decision
@agent(
name="inquiry-classifier",
description="Classifies customer inquiries"
)
class InquiryAgent:
pass
The @agent decorator defines a container for your agent's capabilities.
Step 2: Add a Decision
Decisions are LLM-powered classification or generation points:
@agent(name="inquiry-classifier")
class InquiryAgent:
@decision
def classify(self, ctx):
"""Classify the inquiry type."""
return ctx.llm.classify(
ctx.input.message,
categories=["billing", "technical", "general", "complaint"]
)
Step 3: Add a Workflow
Workflows orchestrate decisions and actions:
@agent(name="inquiry-classifier")
class InquiryAgent:
@workflow
def process_inquiry(self, ctx):
# Classify the inquiry
category = ctx.call(self.classify)
# Return structured result
return {
"category": category,
"message": ctx.input.message,
"confidence": "high"
}
@decision
def classify(self, ctx):
return ctx.llm.classify(
ctx.input.message,
categories=["billing", "technical", "general", "complaint"]
)
Step 4: Run the Agent
from waxell_runtime import RuntimeConfig
# Get runtime configuration
config = RuntimeConfig.get()
# Create agent instance
agent = InquiryAgent()
# Run the workflow
result = config.run(
agent.process_inquiry,
input={"message": "I can't log into my account"}
)
print(result)
# {"category": "technical", "message": "I can't log into my account", "confidence": "high"}
Complete Example
from waxell_sdk import agent, workflow, decision
from waxell_runtime import RuntimeConfig
@agent(
name="inquiry-classifier",
description="Classifies customer inquiries",
version="1.0.0"
)
class InquiryAgent:
@workflow
def process_inquiry(self, ctx):
category = ctx.call(self.classify)
return {
"category": category,
"message": ctx.input.message
}
@decision
def classify(self, ctx):
return ctx.llm.classify(
ctx.input.message,
categories=["billing", "technical", "general", "complaint"]
)
if __name__ == "__main__":
config = RuntimeConfig.get()
agent = InquiryAgent()
result = config.run(
agent.process_inquiry,
input={"message": "My payment didn't go through"}
)
print(f"Classification: {result['category']}")
Next Steps
- Workflows Tutorial - Build complex multi-step workflows
- SDK Reference - Explore all SDK features