Skip to main content

Bub

Bub logo

A hook-first runtime for agents that live alongside people.

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

pip install bub

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.

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

Why Bub

  • Hook-first runtime. Every turn stage is a 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 50 Max tool-use loop iterations
BUB_MAX_TOKENS 16384 Max tokens per model call
BUB_MODEL_TIMEOUT_SECONDS Model call timeout (seconds)

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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bub-0.4.2.tar.gz (150.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bub-0.4.2-py3-none-any.whl (132.1 kB view details)

Uploaded Python 3

File details

Details for the file bub-0.4.2.tar.gz.

File metadata

  • Download URL: bub-0.4.2.tar.gz
  • Upload date:
  • Size: 150.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.6.14

File hashes

Hashes for bub-0.4.2.tar.gz
Algorithm Hash digest
SHA256 139552478786dd069053f0d121385fe156e3c9f1c37549f55d1d7b5c2d7917b1
MD5 33645eb611edb8c76774b8ac2f216626
BLAKE2b-256 ae7e64cf99d10c79a4d4505ec57868e64465213f9d42fc58b1f380d52175c8d6

See more details on using hashes here.

File details

Details for the file bub-0.4.2-py3-none-any.whl.

File metadata

  • Download URL: bub-0.4.2-py3-none-any.whl
  • Upload date:
  • Size: 132.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.6.14

File hashes

Hashes for bub-0.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7353229a9d5134a9971d22c8de079ba37dce39a7ff86870962739c1f79c645b5
MD5 e21c0224c3c511fb12db4ba345093f7c
BLAKE2b-256 75114f51f40199d13e78d216223765090d22e5dbe94294cdd1ff2acb07c02c35

See more details on using hashes here.

Release history Release notifications | RSS feed

0.4.3

2 files

This release

0.4.2 This release

2 files

0.4.1

2 files

0.4.0

2 files

0.3.9

2 files

0.3.8

2 files

0.3.7

2 files

0.3.6

2 files

0.3.5

2 files

0.3.4

2 files

0.3.3

2 files

0.3.2

2 files

0.3.1

2 files

0.3.0

2 files

0.2.3

2 files

0.2.2

2 files

0.2.1

2 files

0.1.1

2 files

0.1

2 files

0.0.0

2 files

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