Skip to main content

sw-agent-init CLI

sw-agent-init CLI

Summary: Interactive project generator for creating new SignalWire agent projects with customizable features.

Overview

The sw-agent-init tool scaffolds new SignalWire agent projects with:

  • Pre-configured project structure
  • Agent class with example SWAIG tool
  • Environment configuration (.env files)
  • Optional debug webhooks for development
  • Test scaffolding with pytest
  • Virtual environment setup

Command Syntax

sw-agent-init [project_name] [options]

Quick Reference

CommandPurpose
sw-agent-initInteractive mode with prompts
sw-agent-init myagentQuick mode with defaults
sw-agent-init myagent --type fullFull-featured project
sw-agent-init myagent --no-venvSkip virtual environment

Modes

Interactive Mode

Run without arguments for guided setup:

sw-agent-init

Interactive mode prompts for:

  1. Project name
  2. Project directory
  3. Agent type (basic or full)
  4. Feature selection
  5. SignalWire credentials
  6. Virtual environment creation

Quick Mode

Provide a project name for quick setup with defaults:

sw-agent-init myagent

Quick mode uses environment variables for credentials if available.

Options

OptionDescription
--type basicMinimal agent with example tool (default)
--type fullAll features enabled
--no-venvSkip virtual environment creation
--dir PATHParent directory for project

Agent Types

Basic Agent

Minimal setup for getting started:

  • Single agent class
  • Example SWAIG tool
  • Test scaffolding
  • Environment configuration
sw-agent-init myagent --type basic

Full Agent

All features enabled:

  • Debug webhooks (console output)
  • Post-prompt summary handling
  • Web UI with status page
  • Example SWAIG tool
  • Test scaffolding
  • Basic authentication
sw-agent-init myagent --type full

Features

Toggle features in interactive mode:

FeatureDescription
Debug webhooksReal-time call data printed to console
Post-prompt summaryCall summary handling after conversations
Web UIStatic file serving with status page
Example SWAIG toolSample get_info tool implementation
Test scaffoldingpytest-based test suite
Basic authenticationHTTP basic auth for SWML endpoints

Generated Project Structure

myagent/
├── agents/
│ ├── __init__.py
│ └── main_agent.py # Main agent implementation
├── skills/
│ └── __init__.py # Reusable skills module
├── tests/
│ ├── __init__.py
│ └── test_agent.py # Test suite using swaig-test
├── web/ # Static files (full type only)
│ └── index.html
├── app.py # Entry point
├── .env # Environment configuration
├── .env.example # Example configuration
├── .gitignore
├── requirements.txt
└── README.md

Environment Variables

The tool auto-detects SignalWire credentials from environment:

VariableDescription
SIGNALWIRE_SPACE_NAMEYour SignalWire space
SIGNALWIRE_PROJECT_IDProject identifier
SIGNALWIRE_TOKENAPI token

Examples

Create Basic Agent

sw-agent-init support-bot
cd support-bot
source .venv/bin/activate
python app.py
sw-agent-init customer-service --type full
cd customer-service
source .venv/bin/activate
python app.py

Create Without Virtual Environment

sw-agent-init myagent --no-venv
cd myagent
pip install -r requirements.txt
python app.py

Create in Specific Directory

sw-agent-init myagent --dir ~/projects
cd ~/projects/myagent

Running the Generated Agent

After creation:

cd myagent
source .venv/bin/activate # If venv was created
python app.py

Output:

SignalWire Agent Server
SWML endpoint: http://0.0.0.0:5000/swml
SWAIG endpoint: http://0.0.0.0:5000/swml/swaig/

Testing the Generated Agent

Run the test suite:

cd myagent
source .venv/bin/activate
pytest tests/ -v

Or use swaig-test directly:

swaig-test agents/main_agent.py --dump-swml
swaig-test agents/main_agent.py --list-tools
swaig-test agents/main_agent.py --exec get_info --topic "SignalWire"

Customizing the Agent

Edit agents/main_agent.py to customize:

  • Prompts and personality
  • Voice and language settings
  • SWAIG tools and handlers
  • Debug and webhook configuration

See the Building Agents chapter for detailed guidance.