Skip to main content

Why Dynamic Prompts Change Everything

Remember changing code just to tweak your AI’s personality? Those days are OVER! With dynamic prompts, you can experiment, test, and perfect your agent’s responses without deploying a single line of code.

A/B Testing

Test different prompts side-by-side

Instant Rollback

Revert to any previous version

Track Performance

See which prompts work best

Versions vs Variants: What’s the Difference?

There’s an important distinction between versions and variants. Vizra ADK supports BOTH seamlessly!

Versions

Track improvements over time. Each version builds on the last, getting better and smarter.
Use for: A/B testing improvements, safe rollbacks, tracking prompt evolution

Variants

Different styles for different contexts. Same capability, different personality.
Use for: User preferences, context-specific responses, brand voices

The Magic: Use Both Together!

File Structure:
Usage Examples:

Getting Started with Dynamic Prompts

When you create an agent using the vizra:make:agent command, it automatically creates a prompt blade file for you in /resources/prompts/YourAgent. This gives you instant access to dynamic prompts without any additional setup!
Quick Example

Real-World Example: Customer Support Agent

Let’s see how versions and variants work together in practice. Imagine evolving a customer support agent over time while maintaining different tones for different customers.
Usage in Production

Blade Templates for Dynamic Prompts

Use Laravel’s Blade templating engine to create dynamic prompts that adapt based on user data, context, and session state.

How It Works

Save your prompts with a .blade.php extension instead of .md:
resources/prompts/customer_support/default.blade.php

Available Variables

Core Variables

  • $agent - Agent info (name, model, etc.)
  • $context - Full AgentContext object
  • $user_input - Current user input
  • $session_id - Session identifier

User & Memory

  • $user, $user_name - User data
  • $memory_context - Previous interactions
  • $tools - Available tools collection
  • $sub_agents - Sub-agents collection

Custom Variables

Add your own variables to inject into the blade prompt with getPromptData():

When to Use What

Use Markdown When:

  • Prompts are mostly static
  • Simple version control needed
  • No dynamic content required

Use Blade When:

  • Need user personalization
  • Conditional logic required
  • Dynamic content injection
Blade templates work seamlessly with the existing versioning system - just use withPromptVersion('name') as usual!

Organizing Your Prompts

Keep your prompts organized with these flexible structures:

Simple Structure (Variants Only)

Versioned Structure (Versions + Variants)

Start simple with just variants. Add versioning when you need to track improvements over time!

CLI Command Mastery

The vizra:prompt command is your Swiss Army knife for prompt management!

Creating Prompts

Terminal

Listing Prompts

Terminal

Import & Export

Terminal

Runtime Magic

Switch prompt versions on the fly - no redeploys needed!

Setting Default Version in Agent Class

You can define a default prompt version directly in your agent class:
Agent with Default Prompt Version

Using Blade Templates at Runtime

Blade templates work seamlessly with the existing prompt versioning system:
Using Blade Templates with Runtime API

Runtime Version Selection

Using Prompt Versions in Code

Advanced Patterns

Advanced Prompt Version Usage

Evaluation Integration

Test different prompt versions systematically with evaluations!

CSV-Driven Testing

evaluation_data.csv
Evaluation Class with Prompt Versions

Configuration Options

Customize prompt versioning behavior in config/vizra-adk.php:
Prompt Configuration

Database Storage (Advanced)

For production environments, enable database storage:
Terminal

Best Practices

Naming Conventions

  • default - Always have one!
  • friendly - Descriptive names
  • 2024_01_15_improved - Date versions
  • v2 - Too vague!

Testing Strategy

  • Start with file-based prompts
  • Test with evaluations
  • A/B test in production
  • Move winners to database

Troubleshooting

Prompt Not Loading?

  1. Check file exists: resources/prompts/{agent_name}/{version}.md
  2. Verify file permissions are readable
  3. Clear cache: php artisan cache:clear
  4. Check agent name matches directory name

Database Prompts Not Working?

  1. Ensure use_database is true in config
  2. Run migrations: php artisan migrate
  3. Check prompt exists: php artisan vizra:prompt list
  4. Verify database connection is working

You’re Now a Dynamic Prompts Pro!

With dynamic prompts, your AI agents can evolve and improve without touching code. Test freely, roll back instantly, and find the perfect voice for every agent. The future of AI development is here!