Skip to main content
Custom variables are accessible in:
  • Agent prompts via custom Jinja2 templates
  • Custom tools via ctx.shared_state.custom_variables

Quick Start

Important: Default prompts don’t render variables. You must provide custom prompts via the prompts parameter.

How Variables Work

When you pass variables to MobileAgent:
  1. Stored in MobileAgentState.custom_variables
  2. Passed to prompt templates as variables dict
  3. Rendered in Jinja2 templates via {% if variables %} blocks
  4. Available to all child agents throughout the workflow
Access Summary:
  • ✅ Agent prompts (via custom Jinja2 templates)
  • ✅ Agents can read and pass to tools as arguments
  • ✅ Custom tools (via ctx.shared_state.custom_variables)

Basic Usage

Available Prompt Keys

Customize these prompts to render variables:
  • manager_system - Manager agent system prompt
  • executor_system - Executor agent system prompt
  • fast_agent_system - FastAgent system prompt
  • fast_agent_user - FastAgent user prompt

Accessing Variables in Custom Tools

Custom tools can access variables via the ctx keyword argument (an ActionContext instance injected automatically):

Use Cases

Parameterized Workflows

Configuration Data


Key Points

  1. Custom prompts required - Default prompts don’t render variables in agent context
  2. Direct access in tools - Custom tools access ctx.shared_state.custom_variables via the ActionContext
  3. Available to all agents - Manager, Executor, FastAgent all receive variables
  4. Jinja2 templates - Use {% if variables %} blocks in custom prompts
  5. Auto-injection - ctx (ActionContext) is injected automatically by the tool registry