# 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.

[Get started](https://mobilebox.dev/docs) [Example on GitHub](https://github.com/mobilebox-dev/mobilebox/tree/main/packages/python/langchain-mobilebox)

Python, 22 lines, the REST API. Android and iPhone over one API.

## Run it in three steps.

Your code owns the phone; the agent only drives it.

[Read the quickstart](https://mobilebox.dev/docs)

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.py` with `MOBILESANDBOX_API_KEY` and `OPENAI_API_KEY` set. 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](https://github.com/mobilebox-dev/mobilebox/blob/main/examples/integrations/langgraph/agent.py) 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](https://mobilebox.dev/blog/install-apk-split-bundles), and [app automation](https://mobilebox.dev/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](https://mobilebox.dev/blog/park-resume-android).

Does it work on iPhone?

Yes. Create the phone with `platform: "ios"` and the agent uses the same tools. See [iPhone and iPad](https://mobilebox.dev/ios).

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](https://mobilebox.dev/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. Guides4 min read](https://mobilebox.dev/blog/android-phone-for-python-ai-agent) [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. Engineering4 min read](https://mobilebox.dev/blog/android-agent-evaluations)

Using another framework? [OpenAI Agents SDK](https://mobilebox.dev/integrations/openai-agents), [CrewAI](https://mobilebox.dev/integrations/crewai), [browser-use](https://mobilebox.dev/integrations/browser-use), [Mastra](https://mobilebox.dev/integrations/mastra), [Vercel AI SDK](https://mobilebox.dev/integrations/vercel-ai-sdk), [Claude Agent SDK](https://mobilebox.dev/integrations/claude-agent-sdk), or [all integrations](https://mobilebox.dev/integrations).

## Try it in your agent in 60 seconds

Paste this into Claude Code, Cursor, Codex or any agent that can read a web page. It asks for your email, gets its own key at once and adds the phone tools; the 6-digit code from your inbox keeps the workspace.

```
Set up Mobilebox for me: read https://mobilebox.dev/setup.md?via=langgraph and follow it.
```

[What your agent reads](https://mobilebox.dev/setup.md?via=langgraph)

## Next questions

- [Can my agent run 50 phones in parallel?](https://mobilebox.dev/blog/run-android-phones-in-parallel?via=next-parallel)

- [Can my agent use an iPhone?](https://mobilebox.dev/ios?via=next-iphone)

- [Can each phone get a residential IP?](https://mobilebox.dev/blog/residential-ip-per-phone?via=next-residential-ip)

- [Does my agent stay logged in between runs?](https://mobilebox.dev/blog/park-resume-android?via=next-logins)

- [Can I watch my agent work live?](https://mobilebox.dev/live-view?via=next-live)

- [What does it cost for a team?](https://mobilebox.dev/blog/mobilebox-pricing-for-teams?via=next-team)

- [How fast do cloud phones start, measured?](https://mobilebox.dev/benchmarks?via=next-benchmarks)

- [Is there a Python package?](https://mobilebox.dev/blog/android-phone-for-python-ai-agent?via=next-python)
