Settings
This page lists all built-in settings for the Bub app layer. The core bub.core.Agent class does not read YAML files or BUB_* environment variables (it takes constructor arguments only). Third-party plugins can register their own configuration sections; see each plugin’s documentation. For initial setup steps, see Configuration.
Precedence
Section titled “Precedence”Settings classes resolve fields in this order (highest priority first):
| Priority | Source | Description |
|---|---|---|
| 1 | Environment variables | BUB_*; read when the settings class is instantiated |
| 2 | .env in current directory |
find_dotenv(usecwd=True); does not override existing system environment variables |
| 3 | YAML config file | Defaults to ~/.bub/config.yml, loaded via configure.load |
| 4 | Field defaults | Default values declared in code |
--workspace,--project, and--enable-channelare CLI flags, not settings fields.- Settings instances are cached process-wide. Modifying
os.environafterensure_config()has been called will not update cached instances; restart the process to apply changes.
Config file and runtime paths
Section titled “Config file and runtime paths”| Path / Variable | Default | Description |
|---|---|---|
~/.bub/config.yml |
DEFAULT_CONFIG_FILE |
Default YAML config file (override via BubFramework(config_file=Path(...))) |
BUB_HOME |
~/.bub |
Runtime data directory (stores session Tapes, managed plugin project, and temporary code-mode files). Note: BUB_HOME does not move the default ~/.bub/config.yml location |
BUB_PROJECT |
<BUB_HOME>/bub-project |
Managed plugin project directory for bub install / uninstall / update (created automatically at the default path; custom paths must already exist) |
Environment variable index
Section titled “Environment variable index”Every YAML setting has a corresponding environment variable (all BUB_* variables can be placed in .env):
| Variable | Default | YAML path | Section |
|---|---|---|---|
BUB_HOME |
~/.bub |
— | Runtime paths |
BUB_PROJECT |
<BUB_HOME>/bub-project |
— | Runtime paths |
BUB_MODEL |
openrouter:openrouter/free |
model |
AgentSettings |
BUB_COMMAND_PREFIX |
, |
command_prefix |
Command prefix |
BUB_FALLBACK_MODELS |
null |
fallback_models |
Models and fallback |
BUB_API_KEY |
unset | api_key |
Credential resolution |
BUB_API_BASE |
unset | api_base |
Credential resolution |
BUB_<PROVIDER>_API_KEY |
unset | — | Credential resolution |
BUB_<PROVIDER>_API_BASE |
unset | — | Credential resolution |
BUB_PROVIDERS |
{} |
providers |
Custom providers |
BUB_MAX_STEPS |
sys.maxsize |
max_steps |
AgentSettings |
BUB_MAX_TOKENS |
16384 |
max_tokens |
AgentSettings |
BUB_SUBAGENT_MAX_CONCURRENCY |
4 |
subagent_max_concurrency |
AgentSettings |
BUB_SUBAGENT_TIMEOUT_SECONDS |
null |
subagent_timeout_seconds |
AgentSettings |
BUB_MODEL_TIMEOUT_SECONDS |
null |
model_timeout_seconds |
AgentSettings |
BUB_CLIENT_ARGS |
{} |
client_args |
client_args |
BUB_COMPLETION_ARGS |
{} |
completion_args |
completion_args |
BUB_VERBOSE |
0 |
verbose |
AgentSettings |
BUB_ENABLED_CHANNELS |
all |
enabled_channels |
ChannelSettings |
BUB_DEBOUNCE_SECONDS |
1.0 |
debounce_seconds |
ChannelSettings |
BUB_MAX_WAIT_SECONDS |
10.0 |
max_wait_seconds |
ChannelSettings |
BUB_ACTIVE_TIME_WINDOW |
60.0 |
active_time_window |
ChannelSettings |
BUB_STREAM_OUTPUT |
false |
stream_output |
ChannelSettings |
BUB_SPILL_THRESHOLD |
4096 |
spill.threshold |
SpillSettings |
BUB_TELEGRAM_TOKEN |
"" |
telegram.token |
TelegramSettings |
BUB_TELEGRAM_ALLOW_USERS |
unset | telegram.allow_users |
TelegramSettings |
BUB_TELEGRAM_ALLOW_CHATS |
unset | telegram.allow_chats |
TelegramSettings |
BUB_TELEGRAM_PROXY |
unset | telegram.proxy |
TelegramSettings |
CODEX_HOME |
~/.codex |
— | Third-party login |
AgentSettings
Section titled “AgentSettings”Defined in src/bub/builtin/settings.py (top-level YAML fields):
@config()class AgentSettings(Settings): model_config = SettingsConfigDict( env_prefix="BUB_", env_parse_none_str="null", extra="ignore", ) model: str = "openrouter:openrouter/free" command_prefix: str = "," fallback_models: list[str] | None = None api_key: str | dict[str, str] | None = None api_base: str | dict[str, str] | None = None providers: dict[str, CustomProvider] = {} max_steps: int = sys.maxsize max_tokens: int = 16384 subagent_max_concurrency: int = 4 subagent_timeout_seconds: int | None = None model_timeout_seconds: int | None = None client_args: dict[str, Any] = {} completion_args: dict[str, Any] = {} verbose: int = 0| Environment variable | Default | YAML key | Description |
|---|---|---|---|
BUB_MODEL |
openrouter:openrouter/free |
model |
Model identifier (provider:model) |
BUB_COMMAND_PREFIX |
, |
command_prefix |
Direct command prefix (non-empty, no whitespace) |
BUB_FALLBACK_MODELS |
null |
fallback_models |
Fallback model list (JSON array in env vars); applies only to the default primary model |
BUB_API_KEY |
unset | api_key |
Global API key string, or provider-to-key mapping dict |
BUB_API_BASE |
unset | api_base |
Global API base URL string, or provider-to-URL mapping dict |
BUB_<PROVIDER>_API_KEY |
unset | — | Provider-specific API key (e.g. BUB_OPENAI_API_KEY) |
BUB_<PROVIDER>_API_BASE |
unset | — | Provider-specific API base URL (e.g. BUB_OPENROUTER_API_BASE) |
BUB_PROVIDERS |
{} |
providers |
Custom provider definitions (JSON object in env vars) |
BUB_MAX_STEPS |
sys.maxsize |
max_steps |
Maximum model Steps per Run (positive integer) |
BUB_MAX_TOKENS |
16384 |
max_tokens |
Default max output tokens per model call (omitted for codex: models) |
BUB_SUBAGENT_MAX_CONCURRENCY |
4 |
subagent_max_concurrency |
Maximum concurrent subagents per process |
BUB_SUBAGENT_TIMEOUT_SECONDS |
null |
subagent_timeout_seconds |
Default timeout in seconds for a subagent run (null means no limit) |
BUB_MODEL_TIMEOUT_SECONDS |
null |
model_timeout_seconds |
Timeout in seconds for one model call (including streaming) |
BUB_CLIENT_ARGS |
{} |
client_args |
Extra kwargs passed to the model client constructor (JSON object) |
BUB_COMPLETION_ARGS |
{} |
completion_args |
Extra kwargs passed to each model generation call (JSON object) |
BUB_VERBOSE |
0 |
verbose |
Log level: 0 (INFO), 1 (DEBUG), 2 (TRACE) |
Command prefix
Section titled “Command prefix”command_prefix |
Example |
|---|---|
, (default) |
,help and ,tape.info are direct commands |
! |
!help is a direct command; ,help is ordinary text |
/ |
In Telegram, invoke via /bub /help |
Credential resolution
Section titled “Credential resolution”For each model call, Bub resolves the first non-empty api_key and api_base in this order:
providers.<name>.api_keyandproviders.<name>.api_base(custom providers);- The provider entry in the
api_key/api_basemapping (BUB_<PROVIDER>_API_KEYandBUB_<PROVIDER>_API_BASEscanned at startup populate this mapping with lower priority than explicitBUB_API_KEY/BUB_API_BASEand YAML values), or the string value ifapi_key/api_baseis a plain string; - Standard provider environment variables without the
BUB_prefix (such asOPENAI_API_KEYorOPENROUTER_API_KEY).
Models and fallback
Section titled “Models and fallback”Common BUB_MODEL prefixes (see Republic providers for the full list):
| Prefix | Provider |
|---|---|
openai: |
OpenAI or any OpenAI-compatible endpoint |
codex: / grok: / github-copilot: |
Account credentials configured via bub login |
openrouter: |
OpenRouter |
anthropic: / google: / azure-openai: |
Native provider APIs |
ollama: / magpie: |
Local model servers |
fallback_models applies only when the active model matches the default model setting (it is skipped when model= is passed in code or after switching models with ,model). Fallbacks are tried in order only when connecting or opening the request stream fails; errors after streaming has started do not retry on another model.
client_args and completion_args
Section titled “client_args and completion_args”Common client_args keys:
| Key | Description |
|---|---|
headers |
Shared by all providers. Overrides the default User-Agent: bub/<version>; provider-specific headers take precedence. |
api_format |
Set to "chat" for OpenAI-compatible /v1/chat/completions endpoints |
timeout / max_retries |
HTTP client request timeout and retry count (overall call timeout is controlled by model_timeout_seconds) |
Common completion_args keys (call-level options override matching keys):
| Key | Description |
|---|---|
max_tokens |
Defaults to BUB_MAX_TOKENS when unset (omitted for codex: calls) |
reasoning_effort |
Overridden by session ,reasoning_effort or call-level options |
extra_body |
Passed through to the provider request body |
Custom providers (providers)
Section titled “Custom providers (providers)”Define custom provider prefixes under providers when connecting to multiple endpoints that share the same protocol (such as internal gateways or relays):
model: proxy:gpt-5.5fallback_models: - openai:gpt-5.5 - relay:claude-sonnet-5providers: proxy: type: openai api_base: https://llm-proxy.example.com/v1 api_key: sk-proxy-... relay: type: anthropic api_base: https://relay.example.com api_key: sk-relay-...| Field | Required | Description |
|---|---|---|
type |
Yes | Underlying Republic provider protocol name (e.g. openai, anthropic) |
api_base |
No | Endpoint URL; falls back to api_base mapping or BUB_<NAME>_API_BASE |
api_key |
No | Endpoint API key; falls back to api_key mapping or BUB_<NAME>_API_KEY |
headers |
No | Request headers for this provider name only. Overrides matching client_args.headers and the default User-Agent, ignoring case. |
Set OpenRouter app attribution for the openrouter: prefix:
providers: openrouter: type: openrouter headers: HTTP-Referer: https://example.com X-OpenRouter-Title: Example AppChannelSettings
Section titled “ChannelSettings”Defined in src/bub/channels/manager.py (top-level YAML fields):
| Environment variable | Default | YAML key | Description |
|---|---|---|---|
BUB_ENABLED_CHANNELS |
all |
enabled_channels |
Channels to enable (comma-separated names, all, or !name exclusions; see CLI channel selection) |
BUB_DEBOUNCE_SECONDS |
1.0 |
debounce_seconds |
Debounce wait timer reset after each active message |
BUB_MAX_WAIT_SECONDS |
10.0 |
max_wait_seconds |
Max wait seconds when buffering unmentioned follow-up messages in a group |
BUB_ACTIVE_TIME_WINDOW |
60.0 |
active_time_window |
Seconds after an active message during which unmentioned group messages join the current batch |
BUB_STREAM_OUTPUT |
false |
stream_output |
Push streaming events to gateway channels (bub chat always forces true) |
Debouncing applies only to channels with needs_debounce=True (such as Telegram).
TelegramSettings
Section titled “TelegramSettings”Defined in src/bub/channels/telegram.py (under telegram: in YAML):
| Environment variable | Default | YAML key | Description |
|---|---|---|---|
BUB_TELEGRAM_TOKEN |
"" |
token |
Telegram bot token; enables the Telegram channel when non-empty |
BUB_TELEGRAM_ALLOW_USERS |
unset | allow_users |
Allowed numeric user IDs or usernames (comma-separated; empty allows all) |
BUB_TELEGRAM_ALLOW_CHATS |
unset | allow_chats |
Allowed chat/group IDs (comma-separated; empty allows all) |
BUB_TELEGRAM_PROXY |
unset | proxy |
HTTP or SOCKS5 proxy URL (e.g. http://127.0.0.1:7890 or socks5://host:port) |
See Gateway: Configure Telegram for allowlist and group-chat rules.
SpillSettings
Section titled “SpillSettings”Defined in src/bub/builtin/spill.py (under spill: in YAML):
| Environment variable | Default | YAML key | Description |
|---|---|---|---|
BUB_SPILL_THRESHOLD |
4096 |
threshold |
Estimated token threshold (4 chars ≈ 1 token) for spilling large tool outputs (0 disables new spills; must be >= 0) |
When a tool output exceeds this threshold and spill.read is available, the full text is written to the spill sidecar and the model receives a short preview and handle (spill.read outputs are not spilled again).
Third-party login variables
Section titled “Third-party login variables”| Variable | Default | Description |
|---|---|---|
CODEX_HOME |
~/.codex |
Directory storing auth.json for bub login codex (overridable via --codex-home) |
Session-persisted settings
Section titled “Session-persisted settings”These three settings are modified via comma commands inside a session and stored in the session Tape (taking effect on the next Turn and persisting across restarts):
| Setting | Command (default prefix ,) |
Effect |
|---|---|---|
model |
,model openai:gpt-5.5 |
Overrides the session model (fallback_models does not apply when switched away from the default model) |
reasoning_effort |
,reasoning_effort high |
Overrides reasoning effort for the session |
code_mode |
,code_mode enable=true |
Enables or disables code mode for the session |
Plugin custom settings
Section titled “Plugin custom settings”Plugins can register their own settings classes with @config:
from pydantic_settings import SettingsConfigDictfrom bub import Settings, config
@config(name="orders")class OrderSettings(Settings): model_config = SettingsConfigDict( env_prefix="BUB_ORDERS_", extra="ignore", ) timeout: int = 30@config(name="x")reads from the top-levelx:section inconfig.yml;@config()reads from the YAML root.- Call
ensure_config(OrderSettings)to get the process-cached instance. bub.configureprovidesload(path),get_config_data(),merge(base, *updates),save(path, data),validate(), andget_value(path, default).
Full configuration file example
Section titled “Full configuration file example”Every field except model is optional:
model: openrouter:openrouter/freecommand_prefix: ","fallback_models: - openai:gpt-5.5api_key: openrouter: sk-or-...api_base: openrouter: https://openrouter.ai/api/v1providers: proxy: type: openai api_base: https://llm-proxy.example.com/v1 api_key: "your-provider-api-key"max_steps: 100max_tokens: 16384subagent_max_concurrency: 4subagent_timeout_seconds: 600model_timeout_seconds: 120client_args: timeout: 60 max_retries: 2completion_args: reasoning_effort: mediumverbose: 0
enabled_channels: alldebounce_seconds: 1.0max_wait_seconds: 10.0active_time_window: 60.0stream_output: false
spill: threshold: 4096
telegram: token: "your-telegram-bot-token" allow_users: "123456789,your_username" allow_chats: "-1001234567890" proxy: socks5://127.0.0.1:7890