promptHasSection

View as MarkdownOpen in Claude

Check whether a named section already exists in the agent’s POM (Prompt Object Model) prompt. Useful for conditionally adding content to avoid duplicate sections.

Parameters

title
stringRequired

The section title to look up. Must match the title passed to promptAddSection().

Returns

booleantrue if a section with the given title exists, false otherwise.

Example

1import { AgentBase } from '@signalwire/sdk';
2
3const agent = new AgentBase({ name: 'assistant', route: '/assistant' });
4agent.promptAddSection('Greeting', { body: 'Always greet the caller by name.' });
5
6if (!agent.promptHasSection('Policies')) {
7 agent.promptAddSection('Policies', { body: 'Follow company guidelines.' });
8}
9await agent.serve();