Medium-Claw: A Persistent AI Companion on Telegram
A Telegram bot backed by the Pi coding agent with autonomous scheduling, persistent memory, cross-session search, and a web dashboard.
I was using OpenClaw as my Telegram-based AI agent but it’s way too bloated for what I actually need. I wanted something lighter that still remembered things, could act on its own, and didn’t lose all context when a session ended. Medium-Claw is a heavily extended fork of mini-claw that turns a simple Telegram bot into a persistent AI companion backed by the Pi coding agent — without all the cruft.
What It Does
At its core: you message the bot on Telegram, and it routes your messages through a Pi agent session with full coding capabilities — shell access, file manipulation, the works. But the interesting parts are everything built on top of that.
Persistent memory. The agent manages its own MEMORY.md and USER.md files as working memory. Facts about you, your preferences, ongoing projects — the agent saves what it considers noteworthy and injects a frozen snapshot into its system prompt. A nudge counter periodically reminds it to consolidate context into memory before it’s lost to session rollover.
Autonomous scheduling. The agent can create one-shot and recurring tasks that fire even when you’re not talking to it. A heartbeat system lets it proactively check in during active hours. Tasks are persisted to JSON with per-chat locking and automatic pruning.
Cross-session search. All messages get recorded to a supplementary SQLite database with FTS5 full-text search. The agent has a recall_conversation tool that can search across every past session, with optional LLM summarization of the results. This is how it finds context from weeks ago that the current session window doesn’t contain.
Session lifecycle management. Automatic session reset on idle timeout or daily schedule, with archived history. Context file truncation keeps the prompt budget under control. The static personality and memory get sent as a system prompt, while each turn carries only the current message — keeping the conversation clean.
Extensions
The bot loads Pi extensions via symlinks, giving the agent access to:
- Brave Search for web queries
- Playwright for browser automation
- Bluesky, Twitter/X, and Fastmail for social and email
- The scheduler and memory tools themselves
All configured through environment variables, all optional.
The Dashboard
A local web server serves a dashboard with live session streaming via SSE, scheduler task snapshots, aggregate analytics (messages, tokens, tools, models), and a session database explorer with full-text search. It’s read-only — just observability into what the agent is doing and has done.
Why Telegram
It’s the interface I already have open on every device. No custom app to build, no browser tab to keep open. The bot is always reachable, and the conversation format maps naturally to how I want to interact with an agent — quick back-and-forth, voice notes when I’m away from a keyboard, and persistent history that Telegram itself handles on the client side.