DISCOVER THE FUTURE OF AI AGENTSarrow_forward

Bub

calendar_todayAdded Apr 23, 2026
categoryAgent & Tooling
codeOpen Source
PythonMulti-Agent SystemAI AgentsAgent FrameworkCLIAgent & ToolingModel & Inference FrameworkDeveloper Tools & CodingAutomation, Workflow & RPA

A lightweight hook-first Python agent runtime for multi-human/multi-agent shared environments, featuring an append-only tape context model for auditable, handoff-capable collaboration.

Bub is a lightweight Python runtime (~200 lines of core code) designed for multi-human and multi-agent shared conversational environments such as group chats. Its design centers on two key mechanisms:

Hook-first Orchestration: Each inbound message flows through a turn pipeline — resolve_session → load_state → build_prompt → run_model → save_state → render_outbound → dispatch_outbound — where every stage is a pluggy-based hook. Developers can override any stage or the entire flow via Python entry-points without forking the runtime itself.

Tape Context Model: Unlike traditional mutable session state, Bub rebuilds context from an append-only tape composed of immutable fact sequences. Anchors mark phase boundaries, and Corrections append new facts to supersede old records without overwriting. This makes every decision auditable, replayable, and forkable, supporting sub-agent history search and handoff tracking.

Bub adopts a channel-agnostic design where the same process_inbound() pipeline drives CLI, Telegram, and custom channels. Built-in capabilities (CLI, Telegram adapter, tools, Skills, model execution) work out of the box but are fully replaceable. Humans and agents share the same runtime boundary and handoff semantics with no special operator class. The plugin system uses entry-points (group="bub") with last-registered-wins priority and no framework privilege paths.

The project supports Comma Commands for inline instructions, skill discovery and authoring based on the agents.md / Agent Skills specifications, and provides Dockerfile and docker-compose.yml for containerized deployment. The default model is openrouter:qwen/qwen3-coder-next, with flexible model provider, API format, and call parameter switching via environment variables.

Installation & Quick Start

pip install bub
git clone https://github.com/bubbuild/bub.git
cd bub
uv sync
uv run bub chat                         # Interactive REPL
uv run bub run "summarize this repo"    # Single turn execution
uv run bub gateway                      # Channel listener mode

CLI Commands

CommandDescription
bub chatInteractive REPL
bub run MESSAGESingle turn execution
bub gatewayChannel listener (Telegram, etc.)
bub installInstall/sync plugin dependencies
bub updateUpgrade plugin dependencies
bub login openaiOpenAI Codex OAuth

Environment Variables

VariableDefaultDescription
BUB_MODELopenrouter:qwen/qwen3-coder-nextModel identifier
BUB_API_KEYProvider API key
BUB_API_BASECustom provider endpoint
BUB_API_FORMATcompletionOptions: completion, responses, messages
BUB_MAX_STEPS50Max tool call loop iterations
BUB_MAX_TOKENS1024Max tokens per model call

Plugin Extension Example

from bub import hookimpl

class EchoPlugin:
    @hookimpl
    def build_prompt(self, message, session_id, state):
        return f"[echo] {message['content']}"

    @hookimpl
    async def run_model(self, prompt, session_id, state):
        return prompt
[project.entry-points."bub"]
echo = "my_package.plugin:EchoPlugin"

Key Source Files

FileResponsibility
src/bub/framework.pyTurn orchestrator
src/bub/hookspecs.pyHook contract definitions
src/bub/builtin/hook_impl.pyBuilt-in hook implementations
src/bub/skills.pySkill discovery and loading

Related Projects

View All arrow_forward

STAY UPDATED

Get the latest AI tools and trends delivered straight to your inbox. No spam, just intelligence.

rocket_launch