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

1from signalwire import AgentBase
2from signalwire import FunctionResult
3
4agent = AgentBase(name="my-agent", route="/agent")
5agent.set_prompt_text("You are a helpful assistant.")
6
7@agent.tool(name="switch_to_billing", description="Switch to the billing context")
8def switch_to_billing(args, raw_data):
9 return (
10 FunctionResult("Let me connect you with billing.")
11 .swml_change_context("billing")
12 )
13
14agent.serve()