Troubleshooting

View as Markdown

Troubleshooting

Common issues and solutions when developing SignalWire voice AI agents.

Quick Diagnostics

CommandPurpose
swaig-test agent.py --dump-swmlVerify SWML generation
swaig-test agent.py --list-toolsList registered functions
swaig-test agent.py --exec funcTest function execution
python agent.pyCheck for startup errors
curl -u "$SWML_BASIC_AUTH_USER:$SWML_BASIC_AUTH_PASSWORD" http://localhost:3000/Test agent endpoint

Startup Issues

Agent Won’t Start

Symptom: Python script exits immediately or with an error.

Common Causes:

  1. Missing dependencies
$## Check if signalwire-agents is installed
$pip show signalwire-agents
$
$## Install if missing
$pip install signalwire-agents
  1. Port already in use
Error: [Errno 48] Address already in use

Solution: Use a different port or stop the existing process.

1agent = AgentBase(name="myagent", route="/", port=3001)
  1. Invalid Python syntax
$## Check syntax
$python -m py_compile agent.py

Import Errors

Symptom: ModuleNotFoundError or ImportError.

ModuleNotFoundError: No module named 'signalwire_agents'

Solutions:

$## Ensure virtual environment is activated
$source venv/bin/activate
$
$## Verify installation
$pip list | grep signalwire
$
$## Reinstall if needed
$pip install --upgrade signalwire-agents

Function Issues

Function Not Appearing

Symptom: Function defined but not showing in --list-tools.

Check 1: Decorator syntax

1## Correct
2@agent.tool(description="My function")
3def my_function(param: str) -> SwaigFunctionResult:
4 return SwaigFunctionResult("Done")
5
6## Wrong: Missing parentheses
7@agent.tool
8def my_function(param: str) -> SwaigFunctionResult:
9 pass
10
11## Wrong: Missing description
12@agent.tool()
13def my_function(param: str) -> SwaigFunctionResult:
14 pass

Check 2: Function defined before agent.run()

1from signalwire_agents import AgentBase
2from signalwire_agents.core.function_result import SwaigFunctionResult
3
4agent = AgentBase(name="test", route="/")
5
6## Functions must be defined before run()
7@agent.tool(description="Test function")
8def test_func() -> SwaigFunctionResult:
9 return SwaigFunctionResult("Test")
10
11## Then run
12if __name__ == "__main__":
13 agent.run()

Function Returns Wrong Response

Symptom: AI receives unexpected or empty response.

Check 1: Return SwaigFunctionResult

1## Correct
2@agent.tool(description="Get status")
3def get_status() -> SwaigFunctionResult:
4 return SwaigFunctionResult("Status is OK")
5
6## Wrong: Returns string instead of SwaigFunctionResult
7@agent.tool(description="Get status")
8def get_status() -> SwaigFunctionResult:
9 return "Status is OK" # This won't work!

Connection Issues

Webhook Not Reached

Symptom: Functions not being called, SignalWire can’t reach agent.

Check 1: Agent is accessible from internet

$## Local testing with ngrok
$ngrok http 3000
$
$## Then use ngrok URL in SignalWire

Check 2: Firewall allows connections

$## Check if port is open
$curl -I http://localhost:3000/

Authentication Failures

Symptom: 401 Unauthorized errors.

Check credentials:

$## Test with credentials
$curl -u username:password http://localhost:3000/

Set in agent:

1agent = AgentBase(
2 name="secure",
3 route="/",
4 basic_auth=("username", "password")
5)

Speech Recognition Issues

Agent Not Hearing Caller

Symptom: AI doesn’t respond to speech.

Adjust confidence threshold:

1agent.set_params({
2 "confidence": 0.5, # Lower = more sensitive
3 "energy_level": 40 # Lower = quieter speech detected
4})

Frequent Interruptions

Symptom: AI gets interrupted too easily.

1agent.set_params({
2 "barge_confidence": 0.8, # Higher = harder to interrupt
3 "barge_min_words": 3 # Require 3+ words to barge
4})

Speech Cut Off Too Early

Symptom: AI thinks caller finished speaking too soon.

1agent.set_params({
2 "end_of_speech_timeout": 1500 # Wait 1.5s of silence (default 700ms)
3})

Timing Issues

Caller Waits Too Long

Symptom: Long delays before AI responds.

Solutions:

1## Use fillers
2@agent.tool(
3 description="Long operation",
4 fillers=["One moment please..."]
5)
6def long_operation() -> SwaigFunctionResult:
7 pass

Call Disconnects Unexpectedly

Symptom: Call ends without explicit hangup.

Check inactivity timeout:

1agent.set_params({
2 "inactivity_timeout": 300000 # 5 minutes (default 10 minutes)
3})

DataMap Issues

Variable Not Substituting

Symptom: ${args.param} appears literally in output.

Check: Parameter name matches

1data_map.add_parameter("city", "string", "City name", required=True)
2
3## URL must use same name
4data_map.add_webhook(
5 url="https://api.example.com?q=${enc:args.city}", # "city" matches
6 ...
7)

Variable Syntax Reference

PatternUsage
${args.param}Function argument
${enc:args.param}URL-encoded argument (use in URLs)
${response.field}API response field
${global_data.key}Global session data

Skill Issues

Skill Not Loading

Symptom: Skill added but functions not available.

Check 1: Skill name is correct

1## List available skills
2print(agent.list_available_skills())
3
4## Add by exact name
5agent.add_skill("datetime")
6agent.add_skill("native_vector_search")

Check 2: Dependencies installed

$## Some skills require additional packages
$pip install "signalwire-agents[search]"

Serverless Issues

Lambda Function Errors

Check 1: Handler configuration

1## handler.py
2from my_agent import agent
3
4def handler(event, context):
5 return agent.serverless_handler(event, context)

Check 2: Lambda timeout

Set Lambda timeout to at least 30 seconds for function processing.

Common Error Messages

ErrorSolution
”Address already in use”Change port or stop existing process
”Module not found”pip install signalwire-agents
”401 Unauthorized”Check basic_auth credentials
”Connection refused”Ensure agent is running
”Function not found”Check function name and decorator
”Invalid SWML”Use swaig-test --dump-swml to debug
”Timeout”Add fillers or optimize function

Getting Help

If issues persist:

  1. Check SignalWire documentation
  2. Review SDK examples in /examples directory
  3. Use swaig-test for diagnostics
  4. Check SignalWire community forums

Advanced Debugging

Enable Debug Logging

1import logging
2logging.basicConfig(level=logging.DEBUG)
3
4# Or for specific components
5logging.getLogger("signalwire_agents").setLevel(logging.DEBUG)

Inspect Raw Request Data

1@agent.tool(description="Debug function")
2def debug_info(args=None, raw_data=None) -> SwaigFunctionResult:
3 import json
4 print("RAW DATA:", json.dumps(raw_data, indent=2))
5 return SwaigFunctionResult("Debug complete")

Test Webhook Connectivity

$# Start agent
$python agent.py
$
$# In another terminal, simulate webhook call (use credentials from agent output or env vars)
$curl -X POST -u "$SWML_BASIC_AUTH_USER:$SWML_BASIC_AUTH_PASSWORD" http://localhost:3000/ \
> -H "Content-Type: application/json" \
> -d '{"function": "my_function", "argument": {"parsed": [{"name": "param", "value": "test"}]}}'

Verify SWML Generation

$# Check for syntax issues
$swaig-test agent.py --dump-swml --raw | python -m json.tool
$
$# Extract specific sections
$swaig-test agent.py --dump-swml --raw | jq '.sections.main[1].ai.prompt'
$swaig-test agent.py --dump-swml --raw | jq '.sections.main[1].ai.SWAIG.functions[].function'

Voice Quality Issues

AI Speaks Too Fast

1# Reduce speech rate via prompt
2agent.prompt_add_section("Speech", "Speak at a moderate pace. Pause briefly between sentences.")

Caller Has Trouble Understanding

1# Add pronunciation rules
2agent.add_pronounce([
3 {"replace": "www", "with": "dub dub dub"},
4 {"replace": ".com", "with": "dot com"},
5 {"replace": "API", "with": "A P I"}
6])

Background Noise Issues

1agent.set_params({
2 "energy_level": 52.0, # Higher = requires louder speech (default 52)
3 "input_sensitivity": 45.0 # Higher = less sensitive to background
4})

Production Issues

High Latency

Symptoms: Long delays before AI responds.

Solutions:

  1. Use fillers for long operations:
1@agent.tool(
2 description="Slow operation",
3 fillers=["One moment please...", "Let me check that..."]
4)
5def slow_operation() -> SwaigFunctionResult:
6 # Long running code
7 pass
  1. Optimize database queries
  2. Use DataMap for simple API calls (executes on SignalWire servers)
  3. Consider caching frequently accessed data

Memory/Resource Issues

Symptoms: Agent crashes or becomes unresponsive.

Solutions:

  1. Don’t store large objects in global_data
  2. Clean up state between calls
  3. Use streaming for large responses
  4. Monitor memory usage in production

Concurrent Call Issues

Symptoms: State bleeds between calls.

Solutions:

  1. Use global_data (per-call) instead of class attributes
  2. Don’t use mutable default arguments
  3. Ensure thread safety for shared resources
1# BAD: Shared state across calls
2class Agent(AgentBase):
3 cart = [] # Shared between all calls!
4
5# GOOD: Per-call state
6agent.set_global_data({"cart": []})

See Also

TopicReference
swaig-test CLIswaig-test Reference
AI parametersAI Parameters
Security best practicesSecurity