Skip to content

πŸ”— Hello World β€” LangChain

Ghost tools inside a LangChain agent. In the video, a LangChain agent harvests subreddits into SQLite β€” the phone does the browsing, the framework does the orchestrating.

  • A phone connected over ADB with USB debugging on (adb devices shows it)
  • Python 3.11+ and an Anthropic (or other LangChain-supported) API key
Terminal window
pip install "ghost-in-the-droid[langchain]"

Ghost’s core never imports the adapter β€” the framework dependency is an optional extra, so plain installs stay lean.

from langchain.chat_models import init_chat_model
from langgraph.prebuilt import create_react_agent
from integrations.langchain import ghost_langchain_tools
tools = ghost_langchain_tools("emulator-5554") # bound to one device
agent = create_react_agent(init_chat_model("anthropic:claude-sonnet-4"), tools)
agent.invoke({"messages": "Open Settings and turn on Wi-Fi"})
# β†’ the agent taps its way through the real phone

Every Ghost tool (tap, type_text, launch_app, get_screen_tree, find_on_screen, screenshots, OCR, …) arrives as a native LangChain tool, so it slots straight into LangGraph or any existing agent loop.

Swap the prompt for something observable:

agent.invoke({"messages": "Read the top post on r/LocalLLaMA in the Reddit app and summarize it"})

The video runs exactly this pattern in a loop β€” five harvests, results written to a local SQLite table.

  • Device binding is locked. The serial you pass to ghost_langchain_tools(...) can’t be overridden by a tool call β€” one toolset drives exactly one phone.
  • Dangerous tools are opt-in. Raw shell and run_skill are excluded unless you pass include_dangerous=True. The allow-list fails closed.

MCP + Claude Code Β· MCP + Codex Β· MCP + Antigravity Β· Ghost CLI Β· Web Chat Β· On-Device Android Β· On-Device iPhone Β· iPhone Duolingo