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

# reset_contexts

> Remove all contexts from the agent, returning it to a no-contexts state.

[ref-agentbase]: /docs/server-sdks/reference/python/agents/agent-base

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

[setdynamicconfig]: /docs/server-sdks/reference/python/agents/agent-base/set-dynamic-config-callback

Remove all contexts from the agent, returning it to a no-contexts state. This is a
convenience wrapper around [`define_contexts().reset()`][contextbuilderreset].

Use it in a [dynamic config callback][setdynamicconfig] when you need to rebuild
contexts from scratch for a specific request.

## **Parameters**

None.

## **Returns**

[`AgentBase`][ref-agentbase] -- Self for method chaining.

## **Example**

```python {5}
from signalwire import AgentBase

def on_dynamic_config(query, body, headers, agent):
    if query.get("transfer"):
        agent.reset_contexts()
        ctx = agent.define_contexts().add_context("default")
        ctx.add_step("route").set_text("Route the caller.")

agent = AgentBase(name="router", route="/router")
agent.set_dynamic_config_callback(on_dynamic_config)
agent.serve()
```