Agents

PomBuilder

View as MarkdownOpen in Claude

PomBuilder provides a fluent interface for creating structured prompts using the Prompt Object Model (POM). POM organizes prompt content into titled sections, subsections, and bullet lists — producing consistent, well-structured prompts that the AI can follow reliably.

Use PomBuilder when you need fine-grained control over prompt structure beyond what set_prompt_text() and prompt_add_section() on AgentBase provide. The builder can render to Markdown or XML format.

PomBuilder requires the signalwire-pom package. Install it with: pip install signalwire-pom

Methods

Examples

Building a structured prompt

1from signalwire.core.pom_builder import PomBuilder
2
3pom = PomBuilder()
4
5pom.add_section(
6 "Role",
7 body="You are a customer service representative for Acme Corp."
8)
9
10pom.add_section(
11 "Guidelines",
12 bullets=[
13 "Always greet the customer by name when available",
14 "Be concise and professional",
15 "Never make promises about timelines you cannot keep"
16 ]
17)
18
19pom.add_section(
20 "Product Knowledge",
21 body="You have access to the product catalog.",
22 subsections=[
23 {
24 "title": "Pricing",
25 "body": "Always quote current prices from the catalog."
26 },
27 {
28 "title": "Returns",
29 "body": "30-day return policy for all items."
30 }
31 ]
32)
33
34# Render as Markdown for use in a prompt
35prompt_text = pom.render_markdown()
36print(prompt_text)

Incremental construction

1from signalwire.core.pom_builder import PomBuilder
2
3pom = PomBuilder()
4
5# Start with a basic section
6pom.add_section("Capabilities", body="You can help with the following:")
7
8# Add bullets incrementally as skills are loaded
9pom.add_to_section("Capabilities", bullet="Weather lookups")
10pom.add_to_section("Capabilities", bullet="Calendar scheduling")
11pom.add_to_section("Capabilities", bullets=[
12 "Order tracking",
13 "Account management"
14])
15
16# Add a subsection
17pom.add_subsection(
18 "Capabilities",
19 "Limitations",
20 body="You cannot process payments directly."
21)
22
23print(pom.render_markdown())

Reconstructing from data

1from signalwire.core.pom_builder import PomBuilder
2
3# Rebuild a PomBuilder from serialized data
4sections = [
5 {"title": "Role", "body": "You are a helpful assistant."},
6 {"title": "Rules", "bullets": ["Be concise", "Be accurate"]}
7]
8
9pom = PomBuilder.from_sections(sections)
10xml_prompt = pom.render_xml()
11print(xml_prompt)