Skip to main content

Overview

Mobilerun uses Jinja2 templates for agent prompts. You can customize agent behavior by passing custom template strings to MobileAgent:
Important: The prompts parameter accepts Jinja2 template strings, not file paths.

Choosing the Manager Prompt

The Manager chooses its prompt in this order:
  1. manager_system passed to MobileAgent
  2. The file set in config.agent.manager.system_prompt
  3. The built-in prompt for the selected stateful or stateless mode

Available Prompt Keys

Context Variables

Each agent has access to different variables in its templates:

Manager (stateful)

  • instruction - User’s goal
  • platform - Active device platform
  • device_date - Current device date/time
  • app_card - App-specific guidance (empty if none available)
  • error_history - List of recent failed actions with details
  • custom_tools_descriptions - Custom tool documentation
  • available_secrets - Available credential IDs
  • variables - Custom variables passed to MobileAgent
  • output_schema - Pydantic model schema (if provided)

Manager (stateless)

  • instruction - User’s goal
  • platform - Active device platform
  • device_date - Current device date/time
  • previous_plan - Plan returned on the previous turn
  • previous_state - Device state from the previous turn
  • memory - Facts saved by earlier Manager responses
  • last_thought - Previous manager rationale
  • progress_summary - Previous cumulative progress summary
  • action_history - Actions and outcomes available for the current turn
  • current_state - Current formatted device state
If you provide manager_system, use the variables and final response format for the selected Manager mode.

Executor

  • instruction - User’s goal
  • app_card - App-specific guidance
  • device_state - Current UI tree
  • plan - Current plan from Manager
  • subgoal - Current subgoal from Manager
  • progress_status - Cumulative progress summary
  • atomic_actions - Available actions (includes custom tools)
  • action_history - Recent actions with outcomes
  • available_secrets - Available credential IDs
  • variables - Custom variables passed to MobileAgent
  • platform - Active device platform

FastAgent

System prompt:
  • tool_descriptions - Available tool signatures
  • available_secrets - Credential IDs
  • available_tools - Tools available to the agent
  • variables - Custom variables
  • output_schema - Output model schema (if provided)
  • parallel_tools - Whether the agent can call multiple tools at once
  • vision - Whether screenshots are included
  • platform - Active device platform
  • screenshot_only - Whether screenshots are used without UI element data
User prompt:
  • goal - Task description
  • variables - Custom variables

Manager Response Format

Custom Manager prompts must return one result block:
  • Use <plan>...</plan> while work remains.
  • In stateful mode, finish with <request_accomplished success="true">...</request_accomplished>, or set success="false" if blocked.
  • In stateless mode, finish with <answer success="true">...</answer>, or set success="false" if blocked.
<thought>, <add_memory>, and <progress_summary> blocks may appear before the result. Valid unfinished response:
Valid stateful final response:
Valid stateless final response:

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 MobileAgent(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)