DroidAgent
- When
reasoning=False: Uses CodeActAgent directly for immediate execution - When
reasoning=True: Uses ManagerAgent (planning) + ExecutorAgent (actions) + ScripterAgent (off-device operations)
DroidAgent.__init__
goalstr - User’s goal or command to executeconfigDroidrunConfig | None - Full configuration object (required if llms not provided). Contains agent settings, LLM profiles, device config, and more.llmsdict[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
toolsTools | None - Pre-configured Tools instance (AdbTools or IOSTools). If None, tools will be created from config.custom_toolsdict | None - Custom tool definitions. Format:{"tool_name": {"signature": "...", "description": "...", "function": callable}}. These are merged with auto-generated credential tools.credentialsdict | None - Direct credential mapping{"SECRET_ID": "value"}. If None, credentials will be loaded from config.credentials if available.variablesdict | None - Custom variables accessible throughout execution. Available in shared_state.custom_variables.output_modelType[BaseModel] | None - Pydantic model for structured output extraction from final answer. If provided, the final answer will be parsed into this model.promptsdict[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).timeoutint - 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
configorllmsmust be provided. Ifllmsis not provided,configis 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=Trueuses Manager/Executor workflow for complex planning.reasoning=Falseuses 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()).