Skip to main content
Dynamic variables resolve at runtime — inject today’s date, timestamps, or custom values into agent prompts without hardcoding.
from praisonaiagents import Agent

agent = Agent(
    name="Researcher",
    instructions="You research news. Today is {{today}}.",
)
agent.start("Find AI news for {{today}}")
The user sends a prompt with {{today}} or custom placeholders; resolvers inject live values before the model runs.

How It Works

Quick Start

1

Use built-in variables in a prompt

from praisonaiagents import Agent

agent = Agent(
    name="Researcher",
    instructions="You research news. Today is {{today}}.",
)

agent.start("Find AI news for {{today}}")
# Resolves to: "Find AI news for June 23, 2026"
2

Register a custom provider

from praisonaiagents import Agent
from praisonaiagents.utils import register_variable_provider

register_variable_provider("author", lambda: "PraisonAI Team")

agent = Agent(name="Writer", instructions="Articles by {{author}}")
agent.start("Write a summary for {{today}}")

Built-in Variables

VariableExample OutputDescription
{{today}}June 23, 2026Human-readable date
{{date}}2026-06-23ISO date format
{{now}}2026-06-23T11:00:00ISO datetime
{{timestamp}}1737280800Unix timestamp
{{uuid}}a1b2c3d4-…Random UUID
{{year}}2026Current year
{{month}}JuneCurrent month name
Variables resolve in Agent.start(), Agent.run(), and workflow execution.

Common Patterns

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"

Direct substitution

from praisonaiagents.utils import substitute_variables

text = substitute_variables("Hello {{today}}", {"topic": "AI"})
Dynamic variables are lazy-loaded — no performance impact when unused.

Best Practices

Prompts with {{today}} stay accurate across sessions without manual updates.
Call register_variable_provider() before creating agents that reference custom variables.
Pass static values via substitute_variables(text, {"topic": "AI"}) alongside built-in dynamic ones.
Workflow task descriptions and goals support the same {{today}}, {{year}}, and custom providers.

Templates

System and prompt templates

Workflows

YAML workflows with variable substitution