Skip to navigation

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

import { AgentBase } from '@signalwire/sdk';
const agent = new AgentBase({ name: 'intake', route: '/intake' });
agent.setDynamicConfigCallback((queryParams, bodyParams, headers, agentCopy) => {
agentCopy.resetContexts();
const ctx = agentCopy.defineContexts().addContext('default');
ctx.addStep('greeting').setText('Greet the caller.');
});
await agent.serve();