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:Getting Started with Dynamic Prompts
When you create an agent using thevizra: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!
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 withgetPromptData():
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
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
Thevizra: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 inconfig/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 names2024_01_15_improved- Date versions- Too vague!v2
Testing Strategy
- Start with file-based prompts
- Test with evaluations
- A/B test in production
- Move winners to database
Troubleshooting
Prompt Not Loading?
- Check file exists:
resources/prompts/{agent_name}/{version}.md - Verify file permissions are readable
- Clear cache:
php artisan cache:clear - Check agent name matches directory name
Database Prompts Not Working?
- Ensure
use_databaseistruein config - Run migrations:
php artisan migrate - Check prompt exists:
php artisan vizra:prompt list - Verify database connection is working