Soul-driven AI agent with permission-hardened tools, token budgets, and multi-channel access. Runs 24/7 from CLI, Telegram or More.
Mercury — Research
Experiments, findings, and notes.
Token Optimization
2026-04-19: Baseline Token Costs
| Component | Est. Tokens |
|---|---|
| soul.md | ~200 |
| persona.md | ~150 |
| taste.md | ~100 |
| heartbeat.md | ~100 |
| Short-term (10 msgs) | ~500 |
| Long-term facts (3) | ~100 |
| User message | ~100 |
| Agent response | ~500 |
| Total per request | ~1,200-1,500 |
Strategies
- Only inject soul+persona by default (~350 tokens)
- Taste and heartbeat loaded selectively
- Compress old conversation into 50-token summaries
- Keyword matching for long-term retrieval (not full scan)
- Daily token budget with hard cap
Telegram Streaming
- Telegram supports streaming via
sendMessageDraftAPI (Bot API 9.5+) - grammY's
@grammyjs/streamplugin handles this natively - Streaming only works in private chats
- Must use
@grammyjs/auto-retryalongside stream plugin (flood limits) - Markdown partial chunks break Telegram's parser — stream plain text, edit with formatting after
LLM Provider Notes
- DeepSeek uses OpenAI-compatible API — same adapter works
- Vercel AI SDK
createOpenAIaccepts custombaseURL— works for any OpenAI-compatible endpoint - Token counting:
js-tiktokenfor OpenAI tokenization. Anthropic uses different tokenizer — approximate.