Tian AI LLM Manager: Process Lifecycle on Mobile Devices
Running a 1.5B parameter LLM on a phone is hard. Keeping it alive is harder.
The Problem
Termux (Android terminal) kills background processes when the device goes to sleep or when memory is low. The LLM process (llama-server) is especially vulnerable because it uses 2-4GB of RAM.
The Solution: LLMManager
Tian AI includes a dedicated process manager that monitors and maintains the LLM process:
class LLMManager : def __init__ ( self ): self . health_check_interval = 30 # seconds self . max_restart_attempts = 5 self . backoff_strategy = [ 1 , 2 , 4 , 8 , 15 ] # seconds
Enter fullscreen mode
Exit fullscreen mode
Key Features
Health Checks
Every 30 seconds, the manager pings the llama-server endpoint. If no response within 5 seconds, it attempts recovery.
Auto-Restart
If the process dies, LLMManager spawns a new instance with the same parameters.…