Skip to main content
Copy the entire content of this page and paste it to your AI assistant. It will then understand LangBot’s overall architecture, how each component is organized, how they connect at runtime, and how to configure the dev environment — without you having to explain it piece by piece.
This page mirrors the AGENTS.md (with CLAUDE.md as a symlink) at each repository root, and serves as LangBot’s “one-page onboarding” for developers and AI assistants.

Project Overview

LangBot is an open-source, LLM-native instant-messaging bot development platform. It provides an out-of-the-box IM bot development experience with built-in Agent, RAG, MCP and other LLM application capabilities, supports mainstream global IM platforms, and exposes rich APIs for custom development. LangBot has a comprehensive web frontend — almost every operation can be performed through it.
  • Backend: Python (>=3.11,<4.0), dependencies managed by uv; the web framework is Quart (the async flavour of Flask). Both the HTTP API and the pre-built frontend are served by the backend on http://127.0.0.1:5300.
  • Frontend: web/ is a Vite + React Router 7 + shadcn/ui + Tailwind CSS SPA, managed by pnpm (note: this is not Next.js — the dev script is literally vite).
  • Plugin system: The Plugin SDK, CLI (lbp), Plugin Runtime, Box (sandbox) Runtime, and the entity/API definitions shared between LangBot and plugins all live in a separate repository: langbot-plugin-sdk. LangBot depends on it via the version-pinned langbot-plugin package in pyproject.toml.

Repository Layout

How Components Are Organized

The core backend package src/langbot/pkg/ is split into loosely-coupled submodules by responsibility: On the plugin side (defined in langbot-plugin-sdk, generated by lbp comp), components are organized around a single BasePlugin. Six component types are currently supported:
  • Command: user-triggered actions (e.g. !weather tokyo).
  • Tool: functions the LLM calls during Agent execution (e.g. fetch weather, query a database).
  • EventListener: handlers for events in the message pipeline (e.g. auto-reply, content filtering).
  • KnowledgeEngine: a custom knowledge-base retrieval/integration implementation used by RAG.
  • Parser: custom parsing of messages/content.
  • Page: a custom web page provided by the plugin, embeddable in the LangBot admin panel.
Each plugin runs in its own process, with its lifecycle managed by the plugin runtime (discover → install deps → load → initialize → register components → ready → terminate).

How Things Connect at Runtime

  • Frontend ↔ Backend: In dev, the frontend runs standalone on :3000 and reaches the backend :5300 via VITE_API_BASE_URL in web/.env; in production the frontend is pre-built into static files served by the backend on the same origin.
  • Backend ↔ Plugin Runtime:
    • When LangBot is started directly (not in a container), the backend spawns the runtime itself and talks over stdio (lightweight/personal use). stdio cannot auto-reconnect — after a disconnect you must restart LangBot; a common failure is an orphan runtime process from a previous backend still holding 5400/5401 — kill it and restart.
    • When LangBot runs in a container, it connects to a standalone runtime over WebSocket (production). Control port defaults to 5400, debug port to 5401. Config: plugin.runtime_ws_url in data/config.yaml (e.g. ws://langbot_plugin_runtime:5400/control/ws).
  • Backend ↔ Box Runtime: The Box subsystem connects to the Box runtime over a control channel (default port 5410), which executes sandboxed code in Docker / nsjail / E2B. Config (box: section of data/config.yaml): box.enabled (master switch), box.backend ('local'/'docker'/'nsjail'/'e2b'), box.runtime.endpoint (external Box runtime URL, e.g. ws://127.0.0.1:5410; empty = local auto-managed). As with the plugin runtime, set that endpoint and start with --standalone-box to connect to an external Box runtime.
  • The full guide for debugging the runtime, CLI and SDK is in Debugging Plugin Runtime, CLI, SDK; detailed flags and architecture are in the langbot-plugin-sdk repo’s AGENTS.md.

Development Environment Setup

Full guide: Development Configuration. Summary:

Backend

On first run the config file is generated at data/config.yaml. SQLite is the default (zero setup); PostgreSQL is supported. Migrations run automatically on startup.

Frontend

Requires Node.js and pnpm.
pnpm dev reads VITE_API_BASE_URL from web/.env so the dev frontend can reach the backend on :5300.

Code Formatting

CI runs lint + format checks. Install the pre-commit hooks so the same checks run locally before each commit:

Database Migrations

After changing ORM models, generate a migration:
autogenerate detects schema changes (add/drop columns and tables, type changes), but data migrations (e.g. mutating JSON field contents) must be hand-written into the generated script. env.py sets render_as_batch=True, so SQLite’s ALTER TABLE limits are handled automatically — no per-database branching needed. Migrations execute automatically on startup.

Development Standards

  • LangBot is a global project: all code comments and docstrings must be in English, and every user-facing string must support i18n (en_US + zh_Hans at minimum, plus ja_JP where the repo already has it).
  • LangBot is adopted in both toC and toB scenarios — always consider compatibility and security.
  • Commit message format: <type>(<scope>): <subject>
    • type: one of feat, fix, docs, style, refactor, perf, test, chore, etc.
    • scope: the affected package/module/file/class.
    • subject: a concise description of the change.

Agent-Facing Surfaces (MCP + Skills)

LangBot is built to be agent-friendly, with three agent-facing surfaces that are kept in lockstep with the HTTP API:
  1. MCP serversrc/langbot/pkg/api/mcp/ exposes a curated subset of the API as MCP tools at /mcp (API-key authenticated, including api.global_api_key from config.yaml). server.py defines the tools (calling the service layer directly); mount.py is the ASGI dispatcher.
  2. In-repo skills — the skills/ directory is the single source of truth for all LangBot agent skills (plugin dev, core dev, deployment, e2e, MCP operations). Docs and the landing page link here rather than copying content.
  3. API-key authapi.global_api_key (config.yaml) authenticates the API and MCP without a login session; see docs/API_KEY_AUTH.md.
Maintenance rule (important). When you add, remove, or change an HTTP API endpoint that should be agent-accessible, you MUST update both the matching MCP tool in src/langbot/pkg/api/mcp/server.py and the relevant skill under skills/ (especially skills/skills/langbot-mcp-ops). API, MCP tools, and skills are one system — drift between them is a bug.

Some Principles

  • Keep it simple, stupid.
  • Entities should not be multiplied unnecessarily.
  • 八荣八耻 (Eight Honors and Eight Shames): Shame in guessing interfaces; honor in carefully checking them. Shame in vague execution; honor in seeking confirmation. Shame in assuming business logic; honor in human confirmation. Shame in inventing interfaces; honor in reusing existing ones. Shame in skipping verification; honor in proactive testing. Shame in breaking architecture; honor in following conventions. Shame in pretending to understand; honor in honest ignorance. Shame in blind changes; honor in careful refactoring.