Cli Swaig Test

View as Markdown

swaig-test CLI

Command-line tool for testing agents and SWAIG functions locally without deploying to production.

Overview

The swaig-test tool loads agent files and allows you to:

  • Generate and inspect SWML output
  • Test SWAIG functions with arguments
  • Simulate serverless environments (Lambda, CGI, Cloud Functions, Azure)
  • Debug agent configuration and dynamic behavior
  • Test DataMap functions with live webhook calls
  • Execute functions with mock call data

Command Syntax

$swaig-test <agent_path> [options]

Quick Reference

CommandPurpose
swaig-test agent.pyList available tools
swaig-test agent.py --dump-swmlGenerate SWML document
swaig-test agent.py --list-toolsList all SWAIG functions
swaig-test agent.py --list-agentsList agents in multi-agent file
swaig-test agent.py --exec fn --param valExecute a function
swaig-test agent.py --help-examplesShow comprehensive examples
swaig-test agent.py --help-platformsShow serverless platform options

Basic Usage

$## Generate SWML document (pretty printed)
$swaig-test agent.py --dump-swml
$
$## Generate raw JSON for piping to jq
$swaig-test agent.py --dump-swml --raw | jq '.'
$
$## List all SWAIG functions
$swaig-test agent.py --list-tools
$
$## Execute a function with CLI-style arguments
$swaig-test agent.py --exec search --query "AI agents" --limit 5
$
$## Execute with verbose output
$swaig-test agent.py --verbose --exec search --query "test"

Actions

Choose one action per command:

ActionDescription
--list-agentsList all agents in the file
--list-toolsList all SWAIG functions in the agent
--dump-swmlGenerate and output SWML document
--exec FUNCTIONExecute a function with CLI arguments
(default)If no action specified, defaults to --list-tools

Common Options

OptionDescription
-v, --verboseEnable verbose output with debug information
--rawOutput raw JSON only (for piping to jq)
--agent-class NAMESpecify agent class for multi-agent files
--route PATHSpecify agent by route (e.g., /healthcare)

SWML Generation

Basic Generation

$## Pretty-printed SWML
$swaig-test agent.py --dump-swml
$
$## Raw JSON for processing
$swaig-test agent.py --dump-swml --raw
$
$## Pretty-print with jq
$swaig-test agent.py --dump-swml --raw | jq '.'

Extract Specific Fields

$## Extract SWAIG functions
$swaig-test agent.py --dump-swml --raw | jq '.sections.main[1].ai.SWAIG.functions'
$
$## Extract prompt
$swaig-test agent.py --dump-swml --raw | jq '.sections.main[1].ai.prompt'
$
$## Extract languages
$swaig-test agent.py --dump-swml --raw | jq '.sections.main[1].ai.languages'

Generate with Fake Call Data

$## With comprehensive fake call data (call_id, from, to, etc.)
$swaig-test agent.py --dump-swml --fake-full-data
$
$## Customize call configuration
$swaig-test agent.py --dump-swml --call-type sip --from-number +15551234567

SWML Generation Options

OptionDefaultDescription
--call-typewebrtcCall type: sip or webrtc
--call-directioninboundCall direction: inbound or outbound
--call-statecreatedCall state value
--from-number(none)Override from/caller number
--to-extension(none)Override to/extension number
--fake-full-datafalseUse comprehensive fake post_data

Function Execution

$## Simple function call
$swaig-test agent.py --exec search --query "AI agents"
$
$## Multiple arguments
$swaig-test agent.py --exec book_reservation \
> --name "John Doe" \
> --date "2025-01-20" \
> --party_size 4
$
$## With verbose output
$swaig-test agent.py --verbose --exec search --query "test"

Type Conversion

Arguments are automatically converted:

TypeExampleNotes
String--name "John Doe"Quoted or unquoted
Integer--count 5Numeric values
Float--threshold 0.75Decimal values
Boolean--active truetrue/false

Legacy JSON Syntax

Still supported for backwards compatibility:

$swaig-test agent.py search '{"query": "AI agents", "limit": 5}'

Function Execution Options

OptionDescription
--minimalUse minimal post_data (function args only)
--fake-full-dataUse comprehensive fake call data
--custom-dataJSON string with custom post_data overrides

Multi-Agent Files

When a file contains multiple agent classes:

$## List all agents in file
$swaig-test multi_agent.py --list-agents
$
$## Use specific agent by class name
$swaig-test multi_agent.py --agent-class SalesAgent --list-tools
$swaig-test multi_agent.py --agent-class SalesAgent --dump-swml
$
$## Use specific agent by route
$swaig-test multi_agent.py --route /sales --list-tools
$swaig-test multi_agent.py --route /support --exec create_ticket --issue "Login problem"

Dynamic Agent Testing

Test agents that configure themselves based on request data:

$## Test with query parameters
$swaig-test dynamic_agent.py --dump-swml --query-params '{"tier":"premium"}'
$
$## Test with custom headers
$swaig-test dynamic_agent.py --dump-swml --header "Authorization=Bearer token123"
$swaig-test dynamic_agent.py --dump-swml --header "X-Customer-ID=12345"
$
$## Test with custom request body
$swaig-test dynamic_agent.py --dump-swml --method POST --body '{"custom":"data"}'
$
$## Test with user variables
$swaig-test dynamic_agent.py --dump-swml --user-vars '{"preferences":{"language":"es"}}'
$
$## Combined dynamic configuration
$swaig-test dynamic_agent.py --dump-swml \
> --query-params '{"tier":"premium","region":"eu"}' \
> --header "X-Customer-ID=12345" \
> --user-vars '{"preferences":{"language":"es"}}'

Data Customization Options

OptionDescription
--user-varsJSON string for userVariables
--query-paramsJSON string for query parameters
--headerAdd HTTP header (KEY=VALUE format)
--overrideOverride specific value (path.to.key=value)
--override-jsonOverride with JSON value (path.to.key=’{“nested”:true}‘)

Advanced Data Overrides

$## Override specific values
$swaig-test agent.py --dump-swml \
> --override call.state=answered \
> --override call.timeout=60
$
$## Override with JSON values
$swaig-test agent.py --dump-swml \
> --override-json vars.custom='{"key":"value","nested":{"data":true}}'
$
$## Combine multiple override types
$swaig-test agent.py --dump-swml \
> --call-type sip \
> --user-vars '{"vip":"true"}' \
> --header "X-Source=test" \
> --override call.project_id=my-project \
> --verbose

Serverless Simulation

Test agents in simulated serverless environments:

PlatformValueDescription
AWS LambdalambdaSimulates Lambda environment
CGIcgiSimulates CGI deployment
Cloud Functionscloud_functionSimulates Google Cloud Functions
Azure Functionsazure_functionSimulates Azure Functions

AWS Lambda Simulation

$## Basic Lambda simulation
$swaig-test agent.py --simulate-serverless lambda --dump-swml
$
$## With custom Lambda configuration
$swaig-test agent.py --simulate-serverless lambda \
> --aws-function-name prod-agent \
> --aws-region us-west-2 \
> --dump-swml
$
$## With Lambda function URL
$swaig-test agent.py --simulate-serverless lambda \
> --aws-function-name my-agent \
> --aws-function-url https://xxx.lambda-url.us-west-2.on.aws \
> --dump-swml
$
$## With API Gateway
$swaig-test agent.py --simulate-serverless lambda \
> --aws-api-gateway-id abc123 \
> --aws-stage prod \
> --dump-swml

AWS Lambda Options

OptionDescription
--aws-function-nameLambda function name
--aws-function-urlLambda function URL
--aws-regionAWS region
--aws-api-gateway-idAPI Gateway ID for API Gateway URLs
--aws-stageAPI Gateway stage (default: prod)

CGI Simulation

$## Basic CGI (host required)
$swaig-test agent.py --simulate-serverless cgi \
> --cgi-host example.com \
> --dump-swml
$
$## CGI with HTTPS
$swaig-test agent.py --simulate-serverless cgi \
> --cgi-host example.com \
> --cgi-https \
> --dump-swml
$
$## CGI with custom script path
$swaig-test agent.py --simulate-serverless cgi \
> --cgi-host example.com \
> --cgi-script-name /cgi-bin/agent.py \
> --cgi-path-info /custom/path \
> --dump-swml

CGI Options

OptionDescription
--cgi-hostCGI server hostname (REQUIRED for CGI simulation)
--cgi-script-nameCGI script name/path
--cgi-httpsUse HTTPS for CGI URLs
--cgi-path-infoCGI PATH_INFO value

Google Cloud Functions Simulation

$## Basic Cloud Functions
$swaig-test agent.py --simulate-serverless cloud_function --dump-swml
$
$## With project configuration
$swaig-test agent.py --simulate-serverless cloud_function \
> --gcp-project my-project \
> --gcp-region us-central1 \
> --dump-swml
$
$## With custom function URL
$swaig-test agent.py --simulate-serverless cloud_function \
> --gcp-function-url https://us-central1-myproject.cloudfunctions.net/agent \
> --dump-swml

GCP Options

OptionDescription
--gcp-projectGoogle Cloud project ID
--gcp-function-urlGoogle Cloud Function URL
--gcp-regionGoogle Cloud region
--gcp-serviceGoogle Cloud service name

Azure Functions Simulation

$## Basic Azure Functions
$swaig-test agent.py --simulate-serverless azure_function --dump-swml
$
$## With environment
$swaig-test agent.py --simulate-serverless azure_function \
> --azure-env production \
> --dump-swml
$
$## With custom function URL
$swaig-test agent.py --simulate-serverless azure_function \
> --azure-function-url https://myapp.azurewebsites.net/api/agent \
> --dump-swml

Azure Options

OptionDescription
--azure-envAzure Functions environment
--azure-function-urlAzure Function URL

Environment Variables

Set environment variables for testing:

$## Set individual variables
$swaig-test agent.py --simulate-serverless lambda \
> --env API_KEY=secret123 \
> --env DEBUG=1 \
> --exec my_function
$
$## Load from environment file
$swaig-test agent.py --simulate-serverless lambda \
> --env-file production.env \
> --dump-swml
$
$## Combine both
$swaig-test agent.py --simulate-serverless lambda \
> --env-file .env \
> --env API_KEY=override_key \
> --dump-swml

DataMap Function Testing

DataMap functions execute their configured webhooks:

$## Test DataMap function (makes actual HTTP requests)
$swaig-test agent.py --exec get_weather --city "New York"
$
$## With verbose output to see webhook details
$swaig-test agent.py --verbose --exec get_weather --city "New York"

Cross-Platform Testing

Compare agent behavior across serverless platforms:

$## Test across all platforms
$for platform in lambda cgi cloud_function azure_function; do
$ echo "Testing $platform..."
$ if [ "$platform" = "cgi" ]; then
$ swaig-test agent.py --simulate-serverless $platform \
> --cgi-host example.com --exec my_function --param value
$ else
$ swaig-test agent.py --simulate-serverless $platform \
> --exec my_function --param value
$ fi
$done
$
$## Compare webhook URLs across platforms
$swaig-test agent.py --simulate-serverless lambda --dump-swml --raw | \
> jq '.sections.main[1].ai.SWAIG.functions[].web_hook_url'
$
$swaig-test agent.py --simulate-serverless cgi --cgi-host example.com \
> --dump-swml --raw | jq '.sections.main[1].ai.SWAIG.functions[].web_hook_url'

Output Options

OptionDescription
--rawMachine-readable JSON output (suppresses logs)
--verboseInclude debug information and detailed output

Extended Help

$## Show platform-specific serverless options
$swaig-test agent.py --help-platforms
$
$## Show comprehensive usage examples
$swaig-test agent.py --help-examples

Complete Workflow Examples

Development Workflow

$## 1. Inspect generated SWML
$swaig-test agent.py --dump-swml --raw | jq '.'
$
$## 2. List available functions
$swaig-test agent.py --list-tools
$
$## 3. Test a specific function
$swaig-test agent.py --exec search --query "test" --verbose
$
$## 4. Test with fake call data
$swaig-test agent.py --exec book_appointment \
> --name "John" --date "2025-01-20" \
> --fake-full-data --verbose

Serverless Deployment Testing

$## Test Lambda configuration
$swaig-test agent.py --simulate-serverless lambda \
> --aws-function-name my-agent \
> --aws-region us-east-1 \
> --dump-swml --raw > swml.json
$
$## Verify webhook URLs are correct
$cat swml.json | jq '.sections.main[1].ai.SWAIG.functions[].web_hook_url'
$
$## Test function execution in Lambda environment
$swaig-test agent.py --simulate-serverless lambda \
> --aws-function-name my-agent \
> --exec process_order --order_id "12345" --verbose

Multi-Agent Testing

$## Discover agents
$swaig-test multi_agent.py --list-agents
$
$## Test each agent
$swaig-test multi_agent.py --agent-class RouterAgent --dump-swml
$swaig-test multi_agent.py --agent-class SalesAgent --list-tools
$swaig-test multi_agent.py --agent-class SupportAgent \
> --exec create_ticket --issue "Cannot login"

Exit Codes

CodeMeaning
0Success
1General error (file not found, invalid args, execution error)

Troubleshooting

IssueSolution
Agent file not foundCheck path is correct
Multiple agents foundUse --agent-class or --route to specify
Function not foundUse --list-tools to see available functions
CGI host requiredAdd --cgi-host for CGI simulation
Invalid JSONCheck --query-params and --body syntax
Import errorsEnsure all dependencies are installed