TELEGRAM
agent.
● bash harness · gemini 3 flash · 38 tools
A self-hosted agent that lives in your Telegram. Runs on a bash harness, talks to Google Vertex AI by default, swaps to 11 other providers with one .env change. Persistent memory across sessions, writes its own tools, restarts itself when something breaks.
real session shape. tool calls visible to the user in-chat.
What it is.
AMA is a long-polling Telegram bot. Each incoming message starts a bash subshell holding a flock on the session id, which calls Google Vertex AI's streaming API, parses tool calls out of the response, runs them, feeds results back, and edits its first reply message as the conversation unfolds.
Everything sits on the filesystem. History is a JSON file per session. Memory is a LanceDB store plus a SQLite session DB with FTS5 search. Tools are bash and python scripts the agent can extend at runtime. No daemons, no message brokers, no Kubernetes.
The harness.
In four parts.
~5,000 lines of bash + python. The interesting stuff fits in core/mix/ and tools/.
Custom tools
38 declared tools. The agent extends them at runtime via custom_tool_manager — write a bash script, register a JSON schema, the next turn can call it. New skills land the same way.
Two-layer memory
LanceDB for semantic recall, SQLite + FTS5 for keyword search across every past session. session_search returns actual messages with ±5-msg context windows — no LLM summarisation tax.
12 model backends
Google, Anthropic, OpenRouter, DeepSeek, Copilot, Groq, KConsole, MiniMax, Mistral, Ollama, xAI, Z.ai. Switch the active model with PROVIDER= + MODEL= in .env. Same tool schema for every one.
Resilience
One flock per session. /stop uses recursive group-kill so subprocesses don't outlive the parent. Idle sessions auto-archive. On API/tool errors, the next turn picks up a heal_request.json describing the fix.
Influences
Patterns we lifted from other harnesses.
AMA isn't a clean-sheet design — it's an opinionated mix of what works elsewhere, ported to a Telegram-first surface.
FTS5 no-LLM session_search, 7-section history compression, async curator pattern.
Deferred tool search, persistent task list, token budget knob, post-batch file-mutation verifier footer.
/stop, /steer, /retry, /undo, /queue — mid-run controls users actually use.
Telegram inline-button clarify, image-part decay, vertex thought_signature flow, skill auto-router.
Run it.
Runs on any linux box with bash, python3, curl, and a Telegram bot token. No docker required.