Static vs Dynamic Agents
Understanding the Difference
Use Static When:
- Same prompt for everyone
- Generic assistant
- Simple IVR
- FAQ bot
Use Dynamic When:
- Personalized greetings
- Caller-specific data
- Account-based routing
- Multi-tenant applications
Static Agents
Static agents have fixed configuration determined at instantiation time.
Example: Static Customer Service Agent
Python
TypeScript
Dynamic Agents
Dynamic agents customize their behavior based on the incoming request using the on_swml_request method.
The on_swml_request Method
Example: Dynamic Personalized Agent
Request Data Fields
The request_data dictionary is the parsed POST body from SignalWire. Call information is nested under the call key:
Always use defensive access when working with request_data.
Dynamic Function Registration
You can also register functions dynamically based on the caller:
Multi-Tenant Applications
Dynamic agents are ideal for multi-tenant scenarios:
Comparison Summary
Best Practices
- Start static, go dynamic when needed - Don’t over-engineer
- Cache expensive lookups - Database calls in
on_swml_requestadd latency - Clear prompts between calls - Use
self.pom.clear()if reusing sections - Log caller info - Helps with debugging dynamic behavior
- Test multiple scenarios - Each caller path needs testing