***

title: set_valid_steps
slug: /reference/python/agents/context-builder/context/set-valid-steps
description: Set which steps can be navigated to from any step in this context.
max-toc-depth: 3
---------------------

For a complete index of all SignalWire documentation pages, fetch https://signalwire.com/docs/llms.txt

[ref-context]: /docs/server-sdks/reference/python/agents/context-builder/context

Set which steps can be navigated to from **any** step in this context. Acts as a
context-level default; step-level `set_valid_steps()` takes precedence when set.

## **Parameters**

<ParamField path="steps" type="list[str]" required={true} toc={true}>
  List of step names. Include `"next"` to allow sequential advancement.
</ParamField>

## **Returns**

[`Context`][ref-context] -- Self for method chaining.

## **Example**

```python {7}
from signalwire import AgentBase

agent = AgentBase(name="my-agent", route="/agent")

contexts = agent.define_contexts()
ctx = contexts.add_context("default")
ctx.set_valid_steps(["next", "cancel"])
ctx.add_step("greet").set_text("Welcome the caller.")
ctx.add_step("collect").set_text("Collect information.")
ctx.add_step("cancel").set_text("Cancel the process and say goodbye.")

agent.serve()
```