LangGraph on Android: phone tools for your graph.
LangGraph agents can automate Android apps through Mobilebox. Its cloud Android phones cost $0.01 a minute and were ready in 19.4 s in our November 2026 benchmark. pip install langchain-mobilebox gives you the phone as LangChain tools, create_agent builds a LangGraph graph around them, and your agent reads a cloud phone’s screen as numbered elements, then taps, types and swipes.
Python, 22 lines, the REST API. Android and iPhone over one API.
- 1
Get a key
Sign up with GitHub and create an API key in the dashboard. New workspaces get free credit.
- 2
Install LangGraph
pip install langchain-mobilebox langchain langchain-openai - 3
Run the example
python agent.pywithMOBILESANDBOX_API_KEYandOPENAI_API_KEYset. It creates a phone, gives the agent one task and deletes the phone, also when the run fails.
The whole example
create_agent returns a compiled LangGraph graph: run it on its own, or add it as a node in your own graph. Add MobileboxScreenshot when your model reads images.
# LangGraph + Mobilebox: a LangGraph agent drives a cloud Android phone with the langchain-mobilebox tools.
# pip install langchain-mobilebox langchain langchain-openai
# MOBILESANDBOX_API_KEY=... OPENAI_API_KEY=... python agent.py
import os
from langchain.agents import create_agent
from langchain_mobilebox import MobileboxAct, MobileboxObserve
from mobilebox import Mobilebox
MODEL = os.environ.get("MODEL", "openai:gpt-5.4-mini") # any LangChain chat model
mb = Mobilebox() # reads MOBILESANDBOX_API_KEY, talks to https://mobilebox.dev
# Your code owns the phone: create it, and always delete it.
phone = mb.create_phone(idle_timeout=120, max_duration=300)
try:
agent = create_agent( # a compiled LangGraph graph: use it alone or as a node in yours
MODEL,
tools=[MobileboxObserve(client=mb), MobileboxAct(client=mb)],
system_prompt=f"You operate the Android phone {phone.id} with the Mobilebox tools. "
"Observe, act, and check each result on the returned screen.",
)
state = agent.invoke({"messages": [("user", "Open Settings > Display and tell me the brightness level.")]})
print(state["messages"][-1].content)
finally:
mb.delete_phone(phone.id)
Ran once against production on 10 November 2026: the agent answered “Brightness level: 83%” in 34 s, and the phone was deleted.
Questions
Before you wire LangGraph to a phone.
Can I use the phone tools inside my own graph?
Yes. MobileboxObserve and MobileboxAct are ordinary LangChain tools: bind them to a model, put them in a ToolNode or hand them to a subgraph. Keep the phone id in state so every node drives the same phone.
Can the agent start and stop its own phones?
Yes. MobileboxToolkit().get_tools() gives it all seven tools, from mobilebox_create_phone to mobilebox_delete_phone, with screenshots and app installs. Tell it in the prompt to delete every phone it creates, also when the task fails.
Can I use MCP instead?
Yes. langchain-mcp-adapters loads the hosted tools from https://mobilebox.dev/mcp with MultiServerMCPClient; the MCP version of this example answered “Brightness level: 83%” on production in 31 s.
Which models can drive the phone?
Any LangChain chat model that calls tools. MODEL takes a provider:model id, for example openai:gpt-5.4-mini.
Can the agent install my app?
Yes. install_app takes a public APK or split-bundle URL, or your code uploads the file over REST; then the agent opens it with {"type":"open_app","package":…}. See installing APKs and split bundles, and app automation for the whole run.
Does the agent stay signed in between runs?
Yes, if you park the phone instead of deleting it: its apps, data and logins wait for the next run, and a parked phone is free. The app’s own session can still expire. See park and resume.
Does it work on iPhone?
Yes. Create the phone with platform: "ios" and the agent uses the same tools. See iPhone and iPad.
What does a run like this cost?
A ready phone costs $0.01 a minute, billed per second with a one-minute minimum; boot time and parked phones are free, so a run like the one above costs about a cent. See pricing.
Read more
Python Android automation for AI agents: pip install mobilebox
Control a cloud Android phone from Python: pip install mobilebox, then one cloud phone per pull request: start it, install the build, walk the flow, screenshot each step, delete it. A tested script, the LangGraph version and what a run costs.
How to evaluate an Android agent without grading its own story
Define testable outcomes, separate environment and control failures, include recovery cases, keep a small acceptance contract and retain evidence for every attempt.
Using another framework? OpenAI Agents SDK, CrewAI, browser-use, Mastra, Vercel AI SDK, Claude Agent SDK, or all integrations.