AgentsAgentBase

add_swaig_query_params

View as MarkdownOpen in Claude

Add query parameters that will be included in all SWAIG webhook URLs generated by this agent. This is particularly useful for preserving dynamic configuration state across SWAIG callbacks — for example, passing a tenant identifier or feature tier so the same configuration is applied when SignalWire invokes tool webhooks.

Parameters

params
dict[str, str]Required

Dictionary of query parameters to merge into every SWAIG URL. Subsequent calls merge into (not replace) the existing set. Pass the same key again to overwrite its value.

Returns

AgentBase — Returns self for method chaining.

Examples

Preserve tier in dynamic config

1from signalwire import AgentBase
2
3agent = AgentBase(name="assistant", route="/assistant")
4agent.set_prompt_text("You are a helpful assistant.")
5
6def dynamic_config(query_params, body_params, headers, agent):
7 tier = query_params.get("tier", "free")
8 if tier == "premium":
9 agent.add_skill("advanced_search")
10 agent.add_swaig_query_params({"tier": tier})
11
12agent.set_dynamic_config_callback(dynamic_config)
13agent.serve()

Multi-tenant routing

1from signalwire import AgentBase
2
3agent = AgentBase(name="support", route="/support")
4agent.set_prompt_text("You are a helpful assistant.")
5
6def dynamic_config(query_params, body_params, headers, agent):
7 tenant_id = query_params.get("tenant_id", "default")
8 agent.add_swaig_query_params({"tenant_id": tenant_id})
9
10agent.set_dynamic_config_callback(dynamic_config)
11agent.serve()