Discover MCPs & agents
Loading MCPs and agents…
Loading MCPs and agents…
Your Digital Companion. Self-hosted Telegram bot orchestrating multiple AI providers (OpenAI, Anthropic, Google, xAI, DeepSeek, Mistral, Alibaba, MiniMax) with autonomous agent capabilities, MCP integrations, and async task execution. Not a tool. A partner.
Fetched from the repository for this visit.

Your Digital Companion. Not a Tool. A Partner.
Self-hosted, asynchronous Telegram bot that orchestrates multiple AI providers, tools, and sub-agents to get real work done.
🌍 Read this in other languages:
Español •
Português (Brasil) •
Українська •
Bahasa Indonesia •
Türkçe •
Русский •
日本語 •
繁體中文 •
简体中文
Chibi is built for the moment you realize you need more than “an AI tool.” You need a partner that can coordinate models, run work in the background, and integrate with your systems - without you babysitting prompts.
Chibi is an asynchronous, self-hosted Telegram-based digital companion that orchestrates multiple AI providers and tools to deliver outcomes: code changes, research syntheses, media generation, and operational tasks.
Chibi supports multiple providers behind a single conversation. Add one key or many - Chibi can route per task.
First-party model providers:
Model resellers and inference aggregators:
Beyond the single built-in CustomOpenAI instance, you can define additional named instances with environment variables. Each OPENAICOMPATIBLE_<NAME>_API_KEY registers a provider named <NAME> that serves chat, speech-to-text and text-to-speech, with the endpoint taken from OPENAICOMPATIBLE_<NAME>_URL; ANTHROPICCOMPATIBLE_<NAME>_API_KEY registers a chat provider the same way (endpoint via ANTHROPICCOMPATIBLE_<NAME>_URL). The number of instances is not limited.
VIDEO_GENERATIONS_LIMIT environment variableExact model availability depends on your configured provider keys and enabled features.
Install Chibi via pip and run it as a command-line application:
# Install the package
pip install chibi-bot
# Set up the agent (add API keys, update settings, etc)
chibi config
# Start the bot
chibi start
The bot will run as a background service. Use CLI commands to manage it.
| Command | Description |
|---|---|
chibi start | Start the bot as a background service |
chibi stop | Stop the running bot |
chibi restart | Restart the bot |
chibi config | Generate or edit configuration |
chibi logs | View bot logs |
Chibi can serve its local clients over the versioned local JSONL protocol:
chibi stdio --tui
chibi stdio --vscode
chibi stdio --pycharm
chibi stdio --neovim
The command is intended to be started by the client frontend, not used interactively. Chibi owns the v1
protocol and supports compatible clients that negotiate the same version. The stdio process writes protocol
frames only to stdout and diagnostics to stderr. Existing Chibi command, tool, permission and moderation
behavior remains authoritative; the client adds no tool policy layer.
Clients can enumerate the selectable models through the models request and pin a model per request with an optional model field on the request frame; the model selection applies to the thread before the prompt runs, and answers stream to the client while the turn is still running.
Create docker-compose.yml:
version: '3.8'
services:
chibi:
image: pysergio/chibi:latest
restart: unless-stopped
environment:
TELEGRAM_BOT_TOKEN: ${TELEGRAM_BOT_TOKEN} # Required
OPENAI_API_KEY: ${OPENAI_API_KEY} # Or any other provider
# Add more API keys as needed
volumes:
- chibi_data:/app/data
volumes:
chibi_data: {}
Get a bot token from @BotFather
Put secrets into .env
Run:
docker-compose up -d
Next:
Each provider requires its own API key. Here are the direct links:
First-party model providers:
Model resellers and inference aggregators:
Creative Tools:
📖 Full guide with setup instructions: chibi.bot/guides/get-api-keys
Paste these into Telegram after you deploy.
Ask me 3 questions to clarify my goal, then propose a plan and execute step 1.
Spawn 3 sub-agents: one to research options, one to draft a recommendation, one to list risks. Return a single decision.
Inspect the project files and summarize what this repo does. Then propose 5 improvements and open a checklist.
Start a background task: gather sources on X and deliver a synthesis in 30 minutes. Keep me updated.
Chibi can keep context while switching providers mid-thread, or choose the best model per step - balancing cost, capability, and speed.
.md files into the skills_dir to add custom ones (a same-name file overrides a built-in) — the agent can load them into its system prompt on demand (load_skill)Connect Chibi to external tools and services (or build your own):
If a tool can be exposed via MCP, Chibi can learn to use it.
Developers
You: “Run the tests and fix what’s broken. I’ll work on the frontend.”
Chibi: *spawns sub-agent, executes tests, analyzes failures, proposes fixes*
Researchers
You: “Research the latest developments in quantum computing. I need a synthesis by tomorrow.”
Chibi: *spawns multiple research agents, aggregates sources, delivers a report*
Creators
You: “Generate a cyberpunk cityscape and compose a synthwave track to match.”
Chibi: *generates an image, creates music, delivers both*
Teams
You: “Review this PR and update the documentation accordingly.”
Chibi: *analyzes changes, suggests improvements, updates docs via MCP*
MAX_HISTORY_TOKENS — context summarization threshold (breaking default change)MAX_HISTORY_TOKENS is the threshold at which Chibi auto-summarizes a conversation to keep context manageable. Its semantics changed: it now compares against the real, provider-reported prompt token count (the entire outgoing request: system prompt + activated skills + tool schemas + tool-call arguments + per-message structural overhead + conversation content) instead of the old heuristic that measured only conversation content + role. The real figure is ~4.8x larger than the old estimate for an identical conversation (see fix_context_size/context_size_accounting_analysis.md for the measured breakdown).
100000 -> 200000. The threshold now aligns with the largest commonly-supported context window (200k tokens, e.g. Anthropic's Claude-class models): summarization fires at the very edge of a 200k window, so large-window models use their full capacity instead of being throttled to ~50% by a threshold sized for the smallest window. This is a deliberate trade-off: for 128k-window models the default no longer sits below the window, and those models are protected by the reactive REACTIVE_CONTEXT_RECOVERY one-shot summarization+retry and by provider failover rather than by the proactive threshold alone. Operators running only small-window (128k or less) models should set an explicit lower value. (Earlier history: the original 64000 default was a history-only estimate that under-counted Cyrillic ~2x and excluded the fixed per-turn overhead (system prompt ~3.7k, tool schemas ~6.8k, activated skills ~5.9k, user_info ~0.75–3k), so it was first re-based to 100000 when the metric became the real provider-reported prompt size.)MAX_HISTORY_TOKENS explicitly in your .env, re-tune it to the ~200k scale (e.g. 100000 -> 200000) unless your deployment deliberately targets small-window models, in which case keep a value that fits your smallest model's context window. If you never set it, the new default applies automatically.REACTIVE_CONTEXT_RECOVERY — one-shot retry after context overflowREACTIVE_CONTEXT_RECOVERY (default: true) is the reactive safety net that complements the proactive MAX_HISTORY_TOKENS threshold. When a provider rejects a request with a typed context_length_exceeded error, Chibi automatically summarizes the conversation history and retries the turn exactly once. If the retry succeeds, the user receives a normal answer (with a short note that context was compressed). If the retry overflows again or recovery fails for any reason, the turn falls back to the existing apology path — the summarization+retry loop can never run more than once per original turn. Set to false to disable reactive recovery and keep the pre-existing behavior (log + apology, no retry).
CONTEXT_FORCED_COMPACTION_ENABLED — automatic compaction after an answerCONTEXT_FORCED_COMPACTION_ENABLED (default: true) enables the post-answer forced-compaction check: after every delivered answer, the thread's context is re-measured in the background and, once it has reached the point where the configured history limit MAX_HISTORY_TOKENS is reached (capped by the model's context window where it is known, so the threshold is never above the physical window), the conversation is unconditionally compacted — the stored history is replaced by a seed whose summary message opens with a [SYSTEM] Context was forcibly compacted marker, followed by a detailed summary, a "Current work in progress" section and a "Background tasks" section. The check is fire-and-forget: it never delays, breaks or alters the delivered answer, and it never runs for sub-agent threads. After a failed attempt the thread backs off for three delivered turns or thirty minutes, whichever comes first. Set to false to disable the automatic check; the agent's own compaction tools (summarize_history, clear_tool_call_history), the trim guard and REACTIVE_CONTEXT_RECOVERY stay in place. The full lifecycle of all compaction layers is described in docs/context-compaction.md.
WORKING_DIR)The agent's working directory - used for terminal commands and reported to the model as its current CWD - is thread-scoped, mirroring how the selected LLM model is bound per thread.
WORKING_DIR setting (default ~/chibi) through the legacy user-level value; fresh deployments inherit the setting directly.set_working_dir tool (LLM-driven only - there is no slash command, available when FILESYSTEM_ACCESS is enabled). This lets two agents in different threads work on different projects simultaneously without interfering.WORKING_DIR setting.~/x becomes /abs/x); untouched defaults keep their raw form./new_thread_with_current_context carries the working directory over together with messages and model preferences.WinError 64)On corporate networks with TLS-inspecting (MITM) proxies, long single-shot LLM requests (30–120 s with no visible traffic) can be killed as "idle" — you see ConnectionResetError / WinError 64 in the logs or a generic connection error in the chat. Chibi automatically retries such failures 4 times with growing waits (~30 s → 180 s) on every provider family and, if all retries fail, reports a clear "connection was interrupted" message instead of a generic error. If the problem persists, set HTTPS_PROXY to your corporate proxy (if it whitelists the AI API hosts) or ask IT to whitelist the provider hosts (api.openai.com, api.anthropic.com, *.googleapis.com, api.mistral.ai).
A note on Gemini specifically: the google-genai SDK silently switches its async transport to aiohttp whenever aiohttp happens to be importable in the environment. In a Chibi install that is always the case — aiohttp arrives as a hard dependency via two independent chains (dashscope, and chromadb → kubernetes), so the issue is not dashscope-only. The bare aiohttp session has no MITM-aware proxy/transport handling, and its keep-alive connections get killed by TLS-inspecting proxies with raw aiohttp.client_exceptions.ServerDisconnectedError tracebacks. Chibi now forces all Gemini async traffic onto its MITM-aware httpx2 client (a maintained httpx fork, injected via client-level HttpOptions(httpx_async_client=...) on every google.genai.Client construction), so Gemini connections go through the same proxy-aware, retrying transport as the other providers.
Chibi can automatically - or manually, if you prefer - fall back to another provider when an LLM request fails on rate limits, server errors, timeouts or network failures (context overflow and moderation errors are deliberately not failover triggers: they have their own recovery paths).
Two environment variables control the behaviour, independently for the main chat and for sub-agent requests:
FAILOVER_CHAIN_MASTER - fallback chain for main chat requestsFAILOVER_CHAIN_SUBAGENT - fallback chain for sub-agent requestsEach value is exactly one of:
| Value | Behaviour |
|---|---|
auto (default) | Automatic fallback ladder (see below) |
disabled | No fallback for the role: a single attempt, honest failure |
provider/model, provider/model, ... | Manual ordered chain |
Examples:
FAILOVER_CHAIN_MASTER=auto
FAILOVER_CHAIN_SUBAGENT=openai/gpt-4o,anthropic/claude-sonnet-4
The pair grammar splits on the first slash only - providers never contain slashes, while model names may (e.g. google/gemini-3.5-flash-lite). Validation is non-fatal by design: every invalid entry (empty, missing slash, empty provider/model part, duplicate pair) produces a clear warning and is skipped - a malformed chain never prevents Chibi from starting.
Within a single request no (provider, model) pair is ever retried, and a provider whose model list could not be enumerated is skipped as a same-model candidate but remains a default-model candidate.
An ordered chain of provider/model pairs fully replaces the auto ladder for that role. The head of the chain is the primary; the cooldown never blocks a manual chain (explicit user choice).
Every fallback attempt is announced - an in-chat warning for master requests, a log warning for sub-agent requests - and the final failure, when it comes, is always reported honestly.
linux/amd64, linux/arm64Please read CONTRIBUTING.md before submitting.
MIT - see LICENSE.
Ready to meet your digital companion?
Get Started →
GitHub checked 39h ago - refresh overdue. Recently viewed repositories target hourly refresh.