Ruggi.Site Ruggi.Site
Tools · Local App · Android / Termux

Pocket Agent 1.9.2

A local LLM agent that lives on your Android phone. One small model is always on and routes each request; two bigger models are loaded only when a job needs them and unloaded as soon as they go idle. A web UI and an OpenAI-compatible API are served to every device on your Wi-Fi. Everything runs offline once the models are downloaded. Bash + PHP + one HTML file: no Python, no Node, no frameworks.

Pocket is the phone-sized sibling of DeckHand, the same idea on a Linux desktop with a GPU: the same page, the same three lines, more tools. The two share one design and one web UI.

Screenshots

Pocket Agent chat screen on a phone: the Auto, Fast, General and Language lines, the Actions switch, the microphone and Send buttons
Chat: the four line buttons, Actions switch, dictation and Send
Pocket Agent sidebar: chats, Dark/Light theme, language switch between EN, HE and ES, and the Models, Help and Settings buttons
Sidebar: chats, theme, interface language, Models, Help, Settings

How it works

other devices ──┐
(PC, tablet…)   ├─► http://PHONE-IP:8080 ──► PHP gateway (token check, routing, streaming)
phone browser ──┘                                │
             ┌───────────────────────────────────┼──────────────────────────┐
             ▼                                   ▼                          ▼
     FAST  (always on)                 GENERAL (on demand)          LANGUAGE (on demand)
     router + quick answers            reasoning, code, tools       other languages, translation
                                       └── only one of these two in RAM at a time (default) ──┘
     watchdog: unloads an idle heavy model after IDLE_SECONDS

What it does

Three model lines

Fast (small, always on, also the router), General (reasoning, code, tools) and Language (multilingual chat and translation). Auto-routing picks a line in about a second, or tap a line to pin it for the whole chat. Each line shows its state with a shape and a word, never colour alone, and a countdown before an idle model unloads.

default models: Qwen3 1.7B · Qwen3 4B · Gemma 3n E4B

Load on demand, unload when idle

A heavy model loads on its first request (3 to 10 s) and is unloaded after IDLE_SECONDS of silence. A RAM guard refuses a load that would not fit instead of letting Android kill Termux. Optionally keep General and Language loaded together when the phone has the RAM.

llama.cpp servers, one per line

Phone protection

Watches battery temperature, battery level, charging state and free RAM. Warm: fewer threads and faster unloading. Hot, low battery or low RAM: heavy models step aside and Fast answers instead, with a "Run anyway" button. Automatic, ask first, or off.

needs Termux:API for heat and battery

Phone actions, with consent

Device status, date and time, location, clipboard, notes, notifications, text messages, contacts, open a page, timers, alarms, speak aloud, and files inside folders you choose. Each action is Auto, Ask me (Approve / Deny card) or Off. Sending messages and calls start Off and can never be Auto.

no "run any command" action exists

Shared folders and a trash

List, read, search, write, move and delete only inside the folders you add, each with Read only / Read and write / Full. Hidden files are invisible, the home folder and system folders are refused, "delete" goes to a recoverable trash and overwrites keep the old version.

injection guard: after reading outside data, every change asks

Speech to text

Tap the microphone, speak, and the words land in the message box. Runs on the phone with whisper.cpp, so no audio leaves it. Spoken language automatic or fixed per language; a large model and a language-specialist model (ivrit.ai) are one tap away in the Models dialog.

llmctl stt-setup builds whisper.cpp on the phone

Text to speech

A Read aloud button on every reply, automatic reading if you want it, and each sentence spoken in the voice of its own language. Three voice sources: the device's own voices, Pocket's own voice (any command you map in data/tts.json, such as Piper or espeak-ng) and the phone's speaker through the Speak aloud action.

llmctl say "…"

Models dialog

Switch the model file of each line, Load now / Unload, pick the speech model, see installed files and delete unused ones, and download more: a short catalog (Qwen3, Qwen3.5, Gemma 3, Gemma 3n, Gemma 4, reasoning distills, TranslateGemma) or any Hugging Face repository and file name. Downloads run in the background and resume.

suggested trios for 12 GB and 16 GB phones in the guide

Translate files

llmctl translate sends .srt subtitles and .json language files through the Language line in batches. Cue numbers and time codes are never sent, keys stay untouched, placeholders like {name} and %s must come back identical, a bad batch is split and retried, and leftovers are listed in a report instead of hidden.

glossary, batch size, source and target language

API and scripts

An OpenAI-compatible /v1/chat/completions endpoint with model = auto, fast, general or lang, so most apps work with a base URL and the token as API key. ask.sh answers one question from the shell, handy for Tasker, cron or Termux:API automations.

token required on every call

Web UI in three languages

One page, dark or light, with the interface in English and other languages (full right-to-left layout where needed). Chats are stored in each browser. A Help viewer shows the guide and the change list offline, with a section menu and search. Install it as an app from the phone's browser for a full-screen Pocket with its own icon.

version in the top bar, Settings warns on a page/server mismatch

Requirements

  • An Android phone with Termux, Termux:API and Termux:Boot from the same source (F-Droid or the Termux GitHub releases; not the Play Store build).
  • About 10 GB of free storage for the three default models (roughly 1.1 + 2.5 + 4.5 GB) and some free RAM: an 8 GB phone runs the Fast line and one heavy model; 12 GB and 16 GB phones can keep more loaded. Smaller trios for tight phones are described in the guide.
  • Battery set to Unrestricted for Termux, and on Android 14 and later Disable child process restrictions in Developer options, so Android does not kill the model server in the background.
  • Wi-Fi for the model downloads. After that, nothing needs the internet.

Install and first run

Download llm-agent-setup.sh to the phone's Downloads folder, then in Termux:

termux-setup-storage                      # grant storage access once
cp ~/storage/downloads/llm-agent-setup.sh ~/
bash llm-agent-setup.sh                   # packages, ~/llm-agent/, your token, the llmctl command, autostart

llmctl pull            # the three models, resumable (or: llmctl pull fast | general | lang)
llmctl start           # loads the Fast model, starts the watchdog and the gateway
llmctl url             # the page address; the second link carries the token, treat it like a password

Open the page on the phone (http://127.0.0.1:8080/) and paste the token from llmctl token into Settings once. From a PC or tablet open http://PHONE-IP:8080/ on the same Wi-Fi. Other commands: llmctl stop | restart | status | logs | test | load | unload | stt-setup | translate | say | version.

Re-running the installer later is an update: your config.env, token and models are kept. Uninstall with llmctl stop; rm -rf ~/llm-agent ~/.termux/boot/llm-agent.sh $PREFIX/bin/llmctl.

Security

  • Every API call needs the token; without it the gateway answers 401. The token lives in config.env; change it any time and llmctl restart.
  • Traffic is plain HTTP inside your own network. Do not port-forward it to the internet; put a VPN in front of it for remote use.
  • Actions are started without a shell, so model text can never become shell syntax. Every action is logged (llmctl actions).

Licence and credits

Pocket Agent is free to use. It stands on these projects, each under its own licence: llama.cpp (MIT) runs the language models; whisper.cpp (MIT) does the dictation; the language-specialist speech model comes from ivrit.ai (Apache-2.0); the models themselves (Qwen, Gemma, DeepSeek distills, TranslateGemma) keep the licences of their authors. For Pocket's own voice, the Piper voices are MIT and the voice "noa" is CC BY 4.0 (credit its author); espeak-ng is GPL-3.0. Termux and its add-ons are GPL-3.0.

The complete source (bash, PHP, one HTML file) is what the installer puts on the phone: ~/llm-agent/. A SOURCES.sha256 list and the builder script let you verify and rebuild the installer byte for byte.

Notes

  • A 4B model is reliable for one or two tool steps, not long plans. For multi-step agents use a bigger model on a PC and keep the phone for quick, private jobs: that is DeckHand.
  • Sustained generation warms the phone and Android throttles after a few minutes; the governor exists for that. Avoid long jobs while charging in a case.
  • This is a personal tool that got tidied up and documented, not an official Termux or llama.cpp project.