Repository navigation
feat!: make code mode a reusable core component - #367
Merged
Merged
Conversation
Move code mode into `bub.core.codemode` so agents built on the kernel alone can
let the model call tools from Python through `run_code`:
code_mode = CodeMode([search, fetch], models="openai:gpt-5")
agent = Agent(tools=[code_mode.run_code], system_prompt=["...", code_mode.prompt])
- `CodeMode` takes a fixed tool list or a per-turn-state selector, an optional
environment, a model resolver for the `republic` bridge and an optional stub dir.
- `LocalEnvironment`/`LocalProcess` move to `bub.environment`.
- `bub.builtin.codemode` keeps Bub's wiring (session setting, environments,
settings-based model resolution, stub files under bub home).
BREAKING CHANGE: `bub.builtin.codemode.code_runner`/`republic_bridge` moved to
`bub.core.codemode.runner`/`republic_bridge`, and `LocalEnvironment` is imported
from `bub.environment`.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
bub | 88da205 | Commit Preview URL Branch Preview URL |
Oct 17 2026, 11:01 AM |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
Code mode used to live in
bub.builtinand depended on app-only parts: settings for model credentials,bub.homefor stub files, and theBubAgentturn state. As a result, users of the kernel alone (pip install bub) could not use it. This PR moves it intobub.core.codemodeas a reusableCodeModecomponent:CodeModeaccepts:Nonedisables code mode).environment=: where code runs. The default is the local subprocess.models=: a default spec or aModelResolverfor therepublicbridge.stub_dir=: write the stub to a file instead of inlining it in the prompt.media_tools=: include theattach_image/audio/videotools.name=: the name of therun_codetool.Nested tool calls still emit
ToolCallStarted/ToolCallFinishedwithcontext.code_mode=True.Impacted modules
bub.core.codemode:CodeMode,stub,runner,runner_child,republic_bridge.LocalEnvironmentandLocalProcessmove tobub.environment.bub.builtin.environmentkeeps onlyenvironment_from_state.bub.builtin.codemodeis now thin wiring: theCODE_MODEinstance, the session setting, Bub's settings-based model resolution, and stub files under bub home.BubAgentusesCODE_MODE.prompt.Breaking changes (no compatibility aliases)
bub.builtin.codemode.code_runner→bub.core.codemode.runnerbub.builtin.codemode.republic_bridge→bub.core.codemode.republic_bridgeLocalEnvironmentandLocalProcess→bub.environmentVerification
uv run ruff check .uv run mypy srcuv run pytest -q: 666 passed, 1 skippedtests/test_core_codemode.py:stub_dirimport bub.core.codemodeloads no app dependenciesAGENTS.md.🤖 Generated with Claude Code