Overview
Droidrun uses Jinja2 templates for agent prompts. You can customize agent behavior by passing custom template strings toDroidAgent
:
prompts
parameter accepts Jinja2 template strings, not file paths.
How It Works
DroidAgent
creates aPromptResolver
with your custom prompts- Each agent checks if you provided a custom template for its key (e.g., “manager_system”)
- If found: uses your custom template
- If not found: loads the default template from Droidrun’s built-in files
- Templates are rendered with context variables specific to each agent
Available Prompt Keys
Key | Agent | When Used |
---|---|---|
manager_system | Manager | Planning and reasoning (only in reasoning mode) |
executor_system | Executor | Action selection (only in reasoning mode) |
codeact_system | CodeAct | Direct execution (always used) |
codeact_user | CodeAct | Task input formatting (always used) |
scripter_system | Scripter | Off-device Python execution (when enabled) |
Context Variables
Each agent has access to different variables in its templates:Manager
instruction
- User’s goaldevice_date
- Current device date/timeapp_card
- App-specific guidance (empty if none available)error_history
- List of recent failed actions with detailscustom_tools_descriptions
- Custom tool documentationscripter_execution_enabled
- Whether Scripter is availableavailable_secrets
- Available credential IDsvariables
- Custom variables passed to DroidAgentoutput_schema
- Pydantic model schema (if provided)
Executor
instruction
- User’s goaldevice_state
- Current UI treesubgoal
- Current subgoal from Manageratomic_actions
- Available actions (includes custom tools)action_history
- Recent actions with outcomes
CodeAct
System prompt:tool_descriptions
- Available tool signaturesavailable_secrets
- Credential IDsvariables
- Custom variablesoutput_schema
- Output model schema (if provided)
goal
- Task descriptionvariables
- Custom variables
Scripter
task
- Task description from Manageravailable_secrets
- Credential IDsvariables
- Custom variables
Example: Custom Manager Prompt
Example: Using Custom Variables
Custom variables let you inject dynamic context into prompts:Jinja2 Syntax Reference
Variables
Conditionals
Loops
Filters
Best Practices
1. Use Clear Structure
2. Handle Missing Data with Conditionals
3. Document Expected Variables
4. Use Variables for Dynamic Behavior
Complete Example
Key Points
- Pass Jinja2 template strings (not file paths) to
DroidAgent(prompts={...})
- Each agent has different available variables in its template
- Use
variables
parameter to inject custom context - Templates are rendered at runtime with current state
- If no custom prompt provided, default templates are used
- Supports full Jinja2 syntax (conditionals, loops, filters)