Skip to main content
Customize prompt templates to control how agents receive instructions and format responses.

Quick Start

1

Basic Templates

Set custom templates:
from praisonaiagents import Agent
from praisonaiagents.config import TemplateConfig

agent = Agent(
    name="Custom Agent",
    instructions="You are a helpful assistant",
    templates=TemplateConfig(
        system="You are an expert in {domain}.",
        prompt="User query: {input}",
        response="Provide a detailed response."
    )
)

Configuration Options

from praisonaiagents.config import TemplateConfig

config = TemplateConfig(
    # System template
    system=None,
    
    # Prompt template
    prompt=None,
    
    # Response template
    response=None,
    
    # Use system prompt
    use_system_prompt=True
)
ParameterTypeDefaultDescription
systemstr | NoneNoneSystem message template
promptstr | NoneNoneUser prompt template
responsestr | NoneNoneResponse format template
use_system_promptboolTrueInclude system prompt in messages

Common Patterns

Pattern 1: Domain Expert Template

from praisonaiagents import Agent
from praisonaiagents.config import TemplateConfig

agent = Agent(
    name="Legal Expert",
    instructions="Legal analysis",
    templates=TemplateConfig(
        system="""You are an expert legal analyst.
        Always cite relevant laws and precedents.
        Be precise and thorough in your analysis."""
    )
)

Pattern 2: Structured Response Template

from praisonaiagents import Agent
from praisonaiagents.config import TemplateConfig

agent = Agent(
    name="Report Agent",
    instructions="Generate reports",
    templates=TemplateConfig(
        response="""Format your response as:
        
## Summary
[Brief overview]

## Details
[Detailed analysis]

## Recommendations
[Action items]"""
    )
)

Pattern 3: No System Prompt

from praisonaiagents import Agent
from praisonaiagents.config import TemplateConfig

agent = Agent(
    name="Raw Agent",
    instructions="Direct interaction",
    templates=TemplateConfig(
        use_system_prompt=False
    )
)

Best Practices

Define agent persona and behavior in the system template.
Ensure consistent output format with response templates.
Each template should have a single, clear purpose.