Skip to main content

Bub

Bub logo

A tiny agent runtime, composable with plugins.

Bub is a small Python runtime for building agents in shared environments. It started in group chats, where multiple humans and agents had to work in the same conversation without hidden state, hand-wavy memory, or framework-specific magic.

Built on agents.md and Agent Skills , Bub stays intentionally small. Every turn stage is a pluggy hook. Builtins are included but replaceable. The same runtime drives CLI, Telegram, and any channel you add.

Website · GitHub

Quick Start

macOS and Linux:

curl -fsSL https://bub.build/install.sh | bash

Windows PowerShell:

powershell -ExecutionPolicy ByPass -c "irm https://bub.build/install.ps1 | iex"

The interactive installer uses a colored preset picker, accepts additional plugin dependencies, and runs bub onboard after installation. For automation, select a preset explicitly; non-interactive installs skip onboarding:

curl -fsSL https://bub.build/install.sh | bash -s -- --preset recommended --dependency extra-plugin
powershell -ExecutionPolicy ByPass -c "& ([scriptblock]::Create((irm https://bub.build/install.ps1))) --preset recommended --dependency extra-plugin"

Or from source:

git clone https://github.com/bubbuild/bub.git
cd bub
uv sync  # enough to run Bub from source

For local development, use make install instead so the website toolchain and prek hooks are installed too.

bub chat                         # interactive session
bub run "summarize this repo"    # one-shot task
bub gateway                      # channel listener mode

Why Bub

  • Composable by design. Every turn stage is a plugin hook. Override one stage or replace the whole flow without forking the runtime.
  • Tape context. Context is rebuilt from append-only records, not carried around as mutable session state. Easier to inspect, replay, and hand off.
  • One runtime across surfaces. The same inbound pipeline runs across CLI, Telegram, and custom channels. Adapters change the surface, not the runtime model.
  • Batteries included. CLI, Telegram, tools, skills, and model execution ship with the core runtime. Use the defaults first, replace them later.
  • Operator equivalence. Humans and agents work inside the same runtime boundaries, with the same evidence trail and handoff model. No hidden operator class.

How It Works

Every inbound message goes through one turn pipeline. Each stage is a hook.

resolve_session → load_state → build_prompt → run_model
                                                   ↓
              dispatch_outbound ← render_outbound ← save_state

Builtins are registered first. External plugins load after them. At runtime, later plugins take precedence. There are no framework-only shortcuts.

Key source files:

Extend It

from bub import hookimpl
from bub.envelope import content_of


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

    @hookimpl
    async def run_model(self, prompt, session_id, state):
        return prompt


echo_plugin = EchoPlugin()
[project.entry-points."bub"]
echo = "my_package.plugin:echo_plugin"

See the Build docs for hook guides, packaging, and plugin structure.

CLI

Command Description
bub chat Interactive REPL
bub run MESSAGE One-shot turn
bub gateway Channel listener (Telegram, etc.)
bub install Install or sync Bub plugin deps
bub update Upgrade Bub plugin deps
bub login openai OpenAI Codex OAuth

Lines starting with , enter internal command mode (,help, ,skill name=my-skill, ,fs.read path=README.md).

bub hooks still exists for diagnostics, but it is hidden from top-level help. bub install and bub update manage a separate uv project for Bub plugins, defaulting to ~/.bub/bub-project or BUB_PROJECT.

Configuration

Variable Default Description
BUB_MODEL openrouter:openrouter/free Model identifier
BUB_API_KEY — Provider key (optional with bub login openai)
BUB_API_BASE — Custom provider endpoint
BUB_CLIENT_ARGS — JSON object forwarded to the underlying model client
BUB_COMPLETION_ARGS — JSON object forwarded to each completion call
BUB_MAX_STEPS unlimited Tool-use loop limit; must be a positive integer
BUB_MAX_TOKENS 16384 Max tokens per model call
BUB_MODEL_TIMEOUT_SECONDS — Model call timeout (seconds)
BUB_SPILL_THRESHOLD 4096 Estimated tokens before tool output spills; 0 disables

Background

Bub is shaped by one constraint: real collaboration is messier than a solo demo. In shared environments, operators need visible boundaries, auditable history, and extension points that do not collapse into framework sprawl.

Read more:

Docs

  • Getting Started — install Bub and run the first turn
  • Concepts — the mental model behind the runtime
  • Channels — run Bub in CLI, Telegram, or your own channel
  • Skills — discover, inspect, and author Agent Skills in Bub
  • Build — write plugins, override hooks, ship tools and skills
  • Deployment — Docker, environment, upgrades

Development

make install
make check
make test
make docs
make docs-test

See CONTRIBUTING.md.

License

Apache-2.0

Metadata

Release files for bub 0.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bub 0.5.0
File Size Uploaded
bub-0.5.0.tar.gz 228.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for bub 0.5.0
File Interpreter ABI Platform
bub-0.5.0-py3-none-any.whl Python 3 none any Details

Total release size: 403.3 kB

Release files / bub-0.5.0.tar.gz

Download URL bub-0.5.0.tar.gz
Size 228.1 kB
Tags Source
SHA-256 checksum
How to use checksums
48a8ceebee0695a9c6fc239046a6b1e4be88c99e9eeb1a88f63de3077bea4fe3
BLAKE2b-256 checksum
How to use checksums
57f49c851926401a3c151fa78e2d7e829c32cba0ee4b1e5666497ed2e9a07ded
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.6.14

Release files / bub-0.5.0-py3-none-any.whl

Download URL bub-0.5.0-py3-none-any.whl
Size 175.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0e4760f47d3da9ba44a3202122307958c9d8a861ff953af45e91cf8c0363324d
BLAKE2b-256 checksum
How to use checksums
27c4f0f6067368432ad83cb40a4411d87c00a2cc83e89c72f804249ce6f80b66
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.6.14
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page