Skip to main content
Dynamic variables are resolved at runtime, allowing you to use current date, time, and other values without hardcoding them.

Built-in Variables

VariableExample OutputDescription
{{today}}January 19, 2026Human-readable date
{{date}}2026-01-19ISO date format
{{now}}2026-01-19T11:00:00ISO datetime
{{timestamp}}1737280800Unix timestamp
{{uuid}}a1b2c3d4-…Random UUID
{{year}}2026Current year
{{month}}JanuaryCurrent month name

Usage in Agent

from praisonaiagents import Agent

# Dynamic variable in prompt
agent = Agent(instructions="You are a news researcher")
result = agent.start("Find AI news for {{today}}")
# Resolves to: "Find AI news for January 19, 2026"

# Dynamic variable in instructions
agent = Agent(
    instructions="You research news. Today is {{today}}.",
    role="Researcher"
)
result = agent.run("What's new in AI?")

Usage in Workflow YAML

framework: praisonai
topic: "Research AI developments for {{today}}"

roles:
  researcher:
    role: AI Researcher
    goal: "Find news for {{month}} {{year}}"
    tasks:
      research:
        description: "Research {{topic}}"
        expected_output: "Summary with sources"

Custom Providers

Register your own dynamic variables:
from praisonaiagents.utils import register_variable_provider

# Simple function
register_variable_provider("author", lambda: "PraisonAI Team")

# Now {{author}} works in any prompt
agent.start("Article by {{author}} on {{today}}")
Dynamic variables are resolved in Agent.start(), Agent.run(), and Workflow execution. The import is lazy-loaded, so there’s no performance impact if you don’t use them.

API Reference

from praisonaiagents.utils import (
    substitute_variables,      # Main function
    get_provider_registry,     # Get the registry
    register_variable_provider # Register custom provider
)

# Direct substitution
text = substitute_variables("Hello {{today}}", {})
# Returns: "Hello January 19, 2026"

# With static variables
text = substitute_variables("Topic: {{topic}} Date: {{today}}", {"topic": "AI"})
# Returns: "Topic: AI Date: January 19, 2026"