reset

View as MarkdownOpen in Claude

Remove all contexts from the builder, returning it to its initial empty state. Use this in a dynamic config callback when you need to rebuild contexts from scratch for a specific request — for example, skipping a greeting context on transfers.

For convenience at the agent level, see AgentBase.reset_contexts(), which wraps define_contexts().reset().

Parameters

None.

Returns

ContextBuilder — Self for method chaining.

Example

1from signalwire import AgentBase
2
3def on_dynamic_config(query, body, headers, agent):
4 if query.get("transfer"):
5 # Wipe the default contexts and rebuild for transfer flow
6 agent.define_contexts().reset()
7 ctx = agent.define_contexts().add_context("default")
8 ctx.add_step("route").set_text("Route the caller.")
9
10agent = AgentBase(name="router", route="/router")
11agent.set_dynamic_config_callback(on_dynamic_config)
12agent.serve()