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.

[user] ama, run pytest on the api package and tell me what failed
bash(command="cd api && pytest -x")
read_code(path="api/tests/test_routes.py")
edit_code(path="api/routes.py")
[ama] test_routes.py::test_get_user failed — assertion on line 42, model returned id as str not int. Patched the schema. Tests green now. [3 tools · 4.1s]

real session shape. tool calls visible to the user in-chat.

writes its own tools · remembers across sessions · 12 providers, 1 prompt · self-heals on failure · writes its own tools · remembers across sessions · 12 providers, 1 prompt · self-heals on failure ·

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

tools/ + brain/tools.json

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.

brain/state/ + LanceDB

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.

core/mix/providers/

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.

core/mix/27_self_heal.sh

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.

Tools 38
Providers 12
Skills 10
Default context 1M gemini-3-flash-preview

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.

01 / RECALL · COMPRESSION
Hermes Agent

FTS5 no-LLM session_search, 7-section history compression, async curator pattern.

02 / SHAPE · UX
Claude Code (cc-oss)

Deferred tool search, persistent task list, token budget knob, post-batch file-mutation verifier footer.

03 / CONTROL
OpenClaw

/stop, /steer, /retry, /undo, /queue — mid-run controls users actually use.

04 / NATIVE
Original to AMA

Telegram inline-button clarify, image-part decay, vertex thought_signature flow, skill auto-router.

Run it.

# clone
$ git clone https://github.com/hangsiahong/mix-autonomous-agent && cd mix-autonomous-agent
# set TG_TOKEN, PROVIDER, MODEL — see .env.example
$ cp .env.example .env && $EDITOR .env
# launch the long-poll loop
$ bash bot.sh

Runs on any linux box with bash, python3, curl, and a Telegram bot token. No docker required.

Self-host the agent.
Your machine, your keys.