Goal-based automation workflows with structured output
Tasks represent automation workflows to be executed on a mobile device. They are defined using natural language goals and can return structured, type-safe results.
Platform (Recommended)
Local Development
With the platform, tasks are configured on platform.mobile-use.ai and executed using PlatformTaskRequest.
Define tasks once on the platform
Update prompts without code changes
Built-in observability and cost tracking
For local development, tasks are defined directly in code with natural language goals.
When creating a task on the platform, you can specify a Locked App Package to restrict the agent to a specific app:
Copy
Name: send-whatsapp-messageAgent Prompt: Send the message "<message>" to <contact> on WhatsAppLocked App Package: com.whatsapp
The task will be displayed with a 🔒 indicator showing the locked package.Using the <locked-app-package> placeholder:You can reference the locked app package in your agent prompt using the <locked-app-package> placeholder:
Copy
Open <locked-app-package> and navigate to settings
This placeholder will be automatically replaced with the configured package name at execution time.
from pydantic import BaseModel, Fieldclass ThemeSettings(BaseModel): dark_mode_enabled: bool = Field(..., description="Whether dark mode is enabled") theme_name: str = Field(..., description="Name of the current theme")result = await agent.run_task( goal="Check the current theme settings", output=ThemeSettings)print(f"Dark mode: {result.dark_mode_enabled}")print(f"Theme: {result.theme_name}")
task = ( agent.new_task("Send a message to Alice") .with_locked_app_package("com.whatsapp") # Android package or iOS bundle ID .build())await agent.run_task(request=task)
# ✅ Good - specificgoal="Open Weather app, check temperature for New York, and tell me if it will rain tomorrow"# ❌ Bad - vaguegoal="Check weather"
Use Pydantic for structured output
Define clear field descriptions to help the LLM understand what to extract
Copy
class WeatherInfo(BaseModel): temperature: float = Field(..., description="Current temperature in Celsius") will_rain_tomorrow: bool = Field(..., description="Whether rain is forecast for tomorrow")
Break complex tasks into simpler ones
Instead of one complex task, run multiple simpler tasks in sequence
Copy
# Step 1: Navigateawait agent.run_task(goal="Open banking app and go to transactions")# Step 2: Extract datatransactions = await agent.run_task( goal="Get the last 5 transactions", output=TransactionList)
Enable tracing for debugging
Always enable tracing when developing or debugging tasks