Skip to main content
The Agent class is the primary entry point for the SDK. It coordinates all components required for mobile automation.

Responsibilities

Device Management

Initializes and manages connections to Android/iOS devices

Server Lifecycle

Starts and stops the Device Controller server

Task Execution

Creates and executes automation tasks

Resource Cleanup

Handles proper cleanup and resource release

Basic Usage

Creating an Agent

Agent Lifecycle

1

Creation

Instantiate the agent with optional configuration
2

Initialization

Connect to device and start servers
3

Execution

Run automation tasks
4

Cleanup

Release resources

Configuration Options

The agent can be configured using the AgentConfigBuilder:

Initialization Options

The init() method accepts several parameters for robust initialization:
If you have zombie servers from previous runs, use agent.clean(force=True) before initializing.

Device Selection

By default, the agent connects to the first available device. You can specify a device explicitly:

Server Configuration

The agent manages the Device Controller server which handles all device interactions:
Executes device actions and captures screen state using native platform tools:
  • Android: Uses ADB (Android Debug Bridge) with UIAutomator2 for UI automation
  • iOS: Uses IDB (iOS Development Bridge) for simulator and device control
Capabilities include:
  • Screenshots and UI hierarchy capture
  • Tap, swipe, scroll gestures
  • App launching and navigation
  • Key press events and text input

Complete Example

Best Practices

Ensure agent.clean() is called even if errors occur
Check the return value of init()
Consider wrapping in a context manager for automatic cleanup

Next Steps

Tasks

Learn about task creation and execution

SDK Reference

Detailed Agent SDK documentation