Skip to main content

How Message Placeholders Work

Define placeholder in prompt template

Create a chat prompt and insert a message placeholder at the desired position. The placeholder is a special message object with type: "placeholder" and a name you’ll reference at runtime.
The placeholder sits between the system message and final user message, ready to accept chat history at runtime.

Fetch prompt at runtime

In your application, fetch the prompt using the ABV SDK. The SDK retrieves the template with placeholders intact, ready for compilation.
The fetched prompt contains the template structure, including all placeholders and variables.

Compile with message arrays

Use the .compile(variables, placeholders) method to resolve both template variables and message placeholders. Pass a dictionary mapping placeholder names to message arrays.
The SDK injects the chat_history array at the placeholder’s position while resolving the {{criticlevel}} variable.

Send compiled messages to LLM

The compiled result is a complete message array ready for the LLM API. ABV handles ordering, role consistency, and variable interpolation automatically.

Best Practices

Name placeholders based on their semantic purpose, not their position.Good:
Avoid:
Clear names make templates self-documenting and prevent compilation errors.
Ensure message arrays passed to placeholders have valid structure (role, content fields) to avoid LLM API errors.
This catches errors early rather than failing at the LLM API call.
Place placeholders in the message sequence that matches conversation flow: system context → examples → history → current input.
This order matches how conversations naturally unfold and how LLMs process context.
Use template variables for simple string substitution and message placeholders for dynamic message arrays.
Compilation:
This combination provides maximum flexibility for both static and dynamic content.
Design your application to handle cases where placeholder arrays might be empty (e.g., first message in a conversation has no history).
ABV handles empty arrays gracefully—the placeholder simply doesn’t insert any messages. Your prompt template works for both first messages and ongoing conversations.

Implementation Examples

Message placeholder UI
  1. Navigate to Prompt Management in ABV dashboard
  2. Create a new chat prompt or edit an existing one
  3. Click Add message placeholder button
  4. Enter a descriptive name (e.g., chat_history, examples)
  5. Position the placeholder in your message sequence
  6. Save the prompt
The placeholder appears as a distinct message type in the prompt editor.
Install ABV SDK:
Create prompt with message placeholder:
Fetch and compile at runtime:
Install ABV SDK:
Set up environment variables:
Create .env file:
.env
Create prompt with placeholder:
Fetch and compile at runtime:
Alternative: Constructor parameters instead of environment variables:

Next Steps

Get Started with Prompt Management

Complete quickstart guide for creating, versioning, and deploying prompts

Prompt Data Model

Deep dive into prompt structure, fields, and versioning

Version Control

Deploy and rollback prompts safely using labels and versions

Prompt Composability

Build complex prompts by composing reusable prompt components