***

title: set_valid_contexts
slug: /reference/python/agents/context-builder/step/set-valid-contexts
description: Set which contexts the agent can navigate to from this step.
max-toc-depth: 3
---------------------

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

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

Set which contexts the agent can navigate to from this step. Overrides any
context-level `set_valid_contexts()` for this step.

## **Parameters**

<ParamField path="contexts" type="list[str]" required={true} toc={true}>
  List of context names that are reachable from this step.
</ParamField>

## **Returns**

[`Step`][ref-step] -- Self for method chaining.

## **Example**

```python {10}
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("transfer")
step.set_text("Transfer the caller to the appropriate department.")
step.set_valid_contexts(["billing", "support"])
billing = contexts.add_context("billing")
billing.add_step("invoice").set_text("Help with billing inquiries.")
support = contexts.add_context("support")
support.add_step("help").set_text("Help with support issues.")

agent.serve()
```