Skip to main content

Prompt Building

There are several ways to build prompts for your agent:

1. Using Prompt Sections (POM)

The Prompt Object Model (POM) provides a structured way to build prompts:

# Add a section with just body text
self.prompt_add_section("Personality", body="You are a friendly assistant.")

# Add a section with bullet points
self.prompt_add_section("Instructions", bullets=[
"Answer questions clearly",
"Be helpful and polite",
"Use functions when appropriate"
])

# Add a section with both body and bullets
self.prompt_add_section("Context",
body="The user is calling about technical support.",
bullets=["They may need help with their account",
"Check for existing tickets"])

For convenience, the SDK also provides wrapper methods that some users may prefer:

# Convenience methods
self.setPersonality("You are a friendly assistant.")
self.setGoal("Help users with their questions.")
self.setInstructions([
"Answer questions clearly",
"Be helpful and polite"
])

These convenience methods call prompt_add_section() internally with the appropriate section titles.

2. Using Raw Text Prompts

For simpler agents, you can set the prompt directly as text:

self.set_prompt_text("""
You are a helpful assistant. Your goal is to provide clear and concise information
to the user. Answer their questions to the best of your ability.
""")

3. Setting a Post-Prompt

The post-prompt is sent to the AI after the conversation for summary or analysis:

self.set_post_prompt("""
Analyze the conversation and extract:
1. Main topics discussed
2. Action items or follow-ups needed
3. Whether the user's questions were answered satisfactorily
""")