> ## Documentation Index
> Fetch the complete documentation index at: https://praison.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Dynamic Variables

> Use {{today}}, {{now}}, {{uuid}} and other dynamic variables in prompts and workflows

Dynamic variables resolve at runtime — inject today's date, timestamps, or custom values into agent prompts without hardcoding.

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
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.

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
graph LR
    P[Prompt with {{today}}] --> R[Resolver]
    R --> V[Built-in Providers]
    R --> C[Custom Providers]
    V --> O[Resolved Text]
    C --> O
    O --> A[Agent]

    classDef input fill:#8B0000,stroke:#7C90A0,color:#fff
    classDef process fill:#189AB4,stroke:#7C90A0,color:#fff
    classDef config fill:#6366F1,stroke:#7C90A0,color:#fff
    classDef output fill:#10B981,stroke:#7C90A0,color:#fff

    class P input
    class R process
    class V,C config
    class O,A output

```

## How It Works

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
sequenceDiagram
    participant User
    participant Agent
    participant Feature as Dynamic Variables

    User->>Agent: Request
    Agent->>Feature: Process request
    Feature-->>Agent: Result    Agent-->>User: Response
```

## Quick Start

<Steps>
  <Step title="Use built-in variables in a prompt">
    ```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    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"
    ```
  </Step>

  <Step title="Register a custom provider">
    ```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    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}}")
    ```
  </Step>
</Steps>

## Built-in Variables

| Variable        | Example Output      | Description         |
| --------------- | ------------------- | ------------------- |
| `{{today}}`     | June 23, 2026       | Human-readable date |
| `{{date}}`      | 2026-06-23          | ISO date format     |
| `{{now}}`       | 2026-06-23T11:00:00 | ISO datetime        |
| `{{timestamp}}` | 1737280800          | Unix timestamp      |
| `{{uuid}}`      | a1b2c3d4-...        | Random UUID         |
| `{{year}}`      | 2026                | Current year        |
| `{{month}}`     | June                | Current month name  |

Variables resolve in `Agent.start()`, `Agent.run()`, and workflow execution.

## Common Patterns

### Workflow YAML

```yaml theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
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

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
from praisonaiagents.utils import substitute_variables

text = substitute_variables("Hello {{today}}", {"topic": "AI"})
```

<Note>
  Dynamic variables are lazy-loaded — no performance impact when unused.
</Note>

## Best Practices

<AccordionGroup>
  <Accordion title="Prefer {{today}} over hardcoded dates">
    Prompts with `{{today}}` stay accurate across sessions without manual updates.
  </Accordion>

  <Accordion title="Register custom providers once at startup">
    Call `register_variable_provider()` before creating agents that reference custom variables.
  </Accordion>

  <Accordion title="Combine with static template variables">
    Pass static values via `substitute_variables(text, {"topic": "AI"})` alongside built-in dynamic ones.
  </Accordion>

  <Accordion title="Use in workflow YAML">
    Workflow task descriptions and goals support the same `{{today}}`, `{{year}}`, and custom providers.
  </Accordion>
</AccordionGroup>

## Related

<CardGroup cols={2}>
  <Card title="Templates" icon="file-code" href="/docs/features/templates">
    System and prompt templates
  </Card>

  <Card title="Workflows" icon="diagram-project" href="/docs/features/workflows">
    YAML workflows with variable substitution
  </Card>
</CardGroup>
