Learn how to use Jinja2 templates to create dynamic system prompts for your AI agents
Variable | Type | Description |
---|---|---|
agent | Object | The agent’s configuration and details |
agent.name | String | The agent’s name |
agent.about | String | Description of the agent |
agent.instructions | Array/String | Agent’s instructions |
user | Object | Information about the current user |
user.name | String | The user’s name |
user.about | String | Description of the user |
session | Object | Current session information |
session.situation | String | The session’s context/situation |
Variable | Type | Description |
---|---|---|
tools | Array | Available tools for the agent |
docs | Array | Relevant documents from searches |
metadata | Object | Custom metadata passed in chat requests |
metadata
field in chat requests allows you to pass dynamic variables that can be used in your system templates. This enables message-level customization without modifying the agent or session.
1. Keep Templates Focused
2. Use Meaningful Variable Names
metadata.customer_tier
metadata.ct
3. Provide Fallbacks
4. Test Template Rendering