Overview
Custom tools are Python functions that extend agent capabilities beyond built-in atomic actions (click, type, swipe). Use cases:- External API calls (webhooks, REST services)
- Data processing and calculations
- Database operations
- Domain-specific logic
Quick Start
Basic Example
Simple custom tool without device access:Tool Structure
All custom tools follow this format:- List only user arguments in
"arguments"(nottoolsorshared_state) toolsandshared_stateare injected automatically as keyword arguments- Use
**kwargsfor forward compatibility - Return type should be
str
Using Tools Instance
Access device via thetools parameter:
tools:
tools.take_screenshot()- Capture screentools.get_state()- Get UI hierarchytools.tap_by_index(index)- Tap elementtools.input_text(text, index)- Type texttools.swipe(x1, y1, x2, y2)- Swipe gesture- All methods from AdbTools/IOSTools
Using Shared State
Access agent state viashared_state:
step_number- Current execution stepaction_history- List of executed actionsaction_outcomes- Success/failure per actionmemory- Agent memory dictcustom_variables- User-provided variablesvisited_packages- Apps visitedcurrent_package_name- Current app packageplan- Current Manager plan- More in
droidrun/agent/droid/events.py

