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 required servers (Screen API, Hardware Bridge)
Task Execution
Creates and executes automation tasks
Resource Cleanup
Handles proper cleanup and resource release
Basic Usage
Creating an Agent
- Platform (Recommended)
- Local Development
With the platform, simply create an agent - no configuration needed:All profiles and task configurations are managed on platform.minitap.ai.
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 theAgentConfigBuilder:
Initialization Options
Theinit() 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 two servers:Screen API Server
Screen API Server
Captures screenshots and UI hierarchies
Hardware Bridge Server
Hardware Bridge Server
Executes device actions via Maestro
Complete Example
- Platform
- Local
Best Practices
Always use try-finally
Always use try-finally
Ensure
agent.clean() is called even if errors occurHandle initialization failures
Handle initialization failures
Check the return value of
init()Use context managers
Use context managers
Consider wrapping in a context manager for automatic cleanup