swml_change_context

View as MarkdownOpen in Claude

Switch to a different conversation context. Contexts represent distinct operational modes (e.g., “sales”, “support”, “billing”), each with their own prompts, tools, and steps defined via ContextBuilder.

Parameters

context_name
strRequired

Name of the context to switch to.

Returns

FunctionResult — self, for chaining.

Example

from signalwire import AgentBase
from signalwire import FunctionResult
agent = AgentBase(name="my-agent", route="/agent")
agent.set_prompt_text("You are a helpful assistant.")
@agent.tool(name="switch_to_billing", description="Switch to the billing context")
def switch_to_billing(args, raw_data):
return (
FunctionResult("Let me connect you with billing.")
.swml_change_context("billing")
)
agent.serve()