AgentsAgentBase

reset_contexts

View as MarkdownOpen in Claude

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

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

Parameters

None.

Returns

AgentBase — Self for method chaining.

Example

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