DroidAgent
- When
reasoning=False
: Uses CodeActAgent directly for immediate execution - When
reasoning=True
: Uses ManagerAgent (planning) + ExecutorAgent (actions) + ScripterAgent (off-device operations)
DroidAgent.__init__
goal
str - User’s goal or command to executeconfig
DroidrunConfig | None - Full configuration object (required if llms not provided). Contains agent settings, LLM profiles, device config, and more. If provided, individual config overrides (agent_config, device_config, etc.) take precedence.llms
dict[str, LLM] | LLM | None - Optional LLM configuration:dict[str, LLM]
: Agent-specific LLMs with keys: “manager”, “executor”, “codeact”, “text_manipulator”, “app_opener”, “scripter”, “structured_output”LLM
: Single LLM instance used for all agentsNone
: LLMs will be loaded from config.llm_profiles
agent_config
AgentConfig | None - Agent configuration override (max_steps, reasoning mode, vision settings, prompts). Overrides config.agent if provided.device_config
DeviceConfig | None - Device configuration override (serial, platform, use_tcp). Overrides config.device if provided.tools
Tools | ToolsConfig | None - Tools configuration:Tools
: Pre-configured Tools instance (AdbTools or IOSTools)ToolsConfig
: Configuration for creating tools (e.g., allow_drag)None
: Tools will be created from config.tools and device_config
logging_config
LoggingConfig | None - Logging configuration override (debug, save_trajectory). Overrides config.logging if provided.tracing_config
TracingConfig | None - Tracing configuration override (enabled). Overrides config.tracing if provided.telemetry_config
TelemetryConfig | None - Telemetry configuration override (enabled). Overrides config.telemetry if provided.custom_tools
dict | None - Custom tool definitions. Format:{"tool_name": {"signature": "...", "description": "...", "function": callable}}
. These are merged with auto-generated credential tools.credentials
CredentialsConfig | dict | None - Credential configuration:CredentialsConfig
: From config.credentials (enabled, file_path)dict
: Direct credential mapping{"SECRET_ID": "value"}
None
: Uses config.credentials if available
variables
dict | None - Custom variables accessible throughout execution. Available in shared_state.custom_variables.output_model
Type[BaseModel] | None - Pydantic model for structured output extraction from final answer. If provided, the final answer will be parsed into this model.prompts
dict[str, str] | None - Custom Jinja2 prompt templates to override defaults. Keys: “codeact_system”, “codeact_user”, “manager_system”, “executor_system”, “scripter_system”. Values: Jinja2 template strings (NOT file paths).timeout
int - Workflow timeout in seconds (default: 1000)
DroidAgent.run
ResultEvent
- Result object with the following attributes:success
(bool): True if task completed successfullyreason
(str): Success message or failure reasonsteps
(int): Number of steps executedstructured_output
(Any): Parsed Pydantic model (if output_model provided, otherwise None)
Event Types
DroidAgent emits various events during execution: Workflow Events:StartEvent
- Workflow startedManagerInputEvent
- Manager planning phase startedManagerContextEvent
- Manager received context for planningManagerResponseEvent
- Manager intermediate responseManagerPlanEvent
- Manager created a planManagerPlanDetailsEvent
- Manager plan detailsExecutorInputEvent
- Executor action phase startedExecutorContextEvent
- Executor received contextExecutorResponseEvent
- Executor intermediate responseExecutorActionEvent
- Executor action detailsExecutorActionResultEvent
- Executor action result detailsExecutorResultEvent
- Executor completed an actionScripterExecutorInputEvent
- ScripterAgent startedScripterExecutorResultEvent
- ScripterAgent completedCodeActExecuteEvent
- CodeActAgent started (direct mode)CodeActResultEvent
- CodeActAgent completedFinalizeEvent
- Workflow finalizingStopEvent
- Workflow completed
TapActionEvent
- UI element tappedSwipeActionEvent
- Swipe gesture performedDragActionEvent
- Drag gesture performedInputTextActionEvent
- Text inputKeyPressActionEvent
- Key press actionStartAppEvent
- App launched
ScreenshotEvent
- Screenshot capturedRecordUIStateEvent
- UI state recordedMacroEvent
- Macro action recorded
Configuration
DroidAgent uses a hierarchical configuration system. See the Configuration Guide for details. Key configuration options:Advanced Usage
Custom Tools instance:Notes
- Config requirement: Either
config
orllms
must be provided. Ifllms
is not provided,config
is required to load LLMs from profiles. - Vision mode: Enabling vision (agent_config.*.vision = True) increases token usage as screenshots are sent to the LLM.
- Reasoning mode:
reasoning=True
uses Manager/Executor workflow for complex planning.reasoning=False
uses CodeActAgent for direct execution. - Safe execution: When enabled, restricts imports and builtins in CodeActAgent and ScripterAgent (see safe_execution config).
- Timeout: Default is 1000 seconds. Increase for long-running tasks.
- Credentials: Credentials are automatically injected as custom tools (e.g.,
get_username()
,get_password()
).