resetContexts

View as MarkdownOpen in Claude

Remove every context defined on this agent’s internal ContextBuilder, returning the builder to its initial state. Convenience wrapper around defineContexts().reset(). Use this inside a dynamic-config callback when you need to rebuild contexts from scratch for a specific request.

Parameters

None.

Returns

AgentBase — Returns this for method chaining.

Example

1import { AgentBase } from '@signalwire/sdk';
2
3const agent = new AgentBase({ name: 'intake', route: '/intake' });
4
5agent.setDynamicConfigCallback((queryParams, bodyParams, headers, agentCopy) => {
6 agentCopy.resetContexts();
7 const ctx = agentCopy.defineContexts().addContext('default');
8 ctx.addStep('greeting').setText('Greet the caller.');
9});
10
11await agent.serve();