set_valid_steps

View as MarkdownOpen in Claude

Set which steps the agent can navigate to from this step.

Parameters

steps
list[str]Required

List of step names within the same context. Use "next" to allow sequential advancement to the next step in order.

Returns

Step — Self for method chaining.

Example

from signalwire import AgentBase
agent = AgentBase(name="my-agent", route="/agent")
contexts = agent.define_contexts()
ctx = contexts.add_context("default")
ctx.add_step("greet").set_text("Welcome the caller.")
step = ctx.add_step("collect_info")
step.set_text("Collect the caller's information.")
step.set_valid_steps(["process_request", "escalate"])
ctx.add_step("process_request").set_text("Process the caller's request.")
ctx.add_step("escalate").set_text("Escalate to a human agent.")
agent.serve()