Skip to content

refactor: use Republic for builtin models and account authentication - #349

Merged
frostming merged 9 commits into
devfrom
refactor/republic-provider-migration
Oct 13, 2026
Merged

frostming merged 9 commits into
devfrom
refactor/republic-provider-migration

Conversation

@PsiACE

@PsiACE PsiACE commented Oct 9, 2026 •

Copy link
Copy Markdown
Member

Builtin model requests use Republic for provider authentication, message encoding and streaming. Bub owns turn orchestration, hooks, tool execution and tape storage, and converts its persisted messages into Republic messages at the request boundary.

The builtin contract uses text/media blocks with kind, MIME type and URL, flat Republic tool-call fields, and native token usage fields. Reasoning, opaque provider data and tool metadata survive tape reload and replay for the same provider/model. Named endpoints keep independent credentials. The runtime consumes a Republic stream directly and reads completed outcomes from Stream.response. Partial event data supports hook errors and cancellation traces. Fallback applies before a stream opens; incomplete streams raise an error before tool execution. Republic owns stream completion. Model and stream contexts close owned HTTP clients on completion, failure and cancellation while preserving caller-supplied clients.

ChatGPT plan access uses codex:<model> and bub login codex, with Codex CLI file credentials, --device-auth, and an optional credential directory. openai:<model> uses API credentials. Provider names and protocol defaults follow Republic; onboarding includes Magpie and saves api_format: chat for Chat Completions services. Provider options and chat options pass directly to Republic. Bub supplies the tools, runtime token limit and session reasoning chat option. Provider-specific fields go in extra_body; Republic deep-merges provider defaults with request extras and applies explicit wire fields last.

English and Chinese documentation describe the current commands, settings and message contracts. Agent and channel tests use isolated fixtures; provider tests verify native fields and actual HTTP requests. Behavior coverage includes hooks, tool handlers, subprocess login, stream outcomes, credential isolation, cancellation and persisted replay, including replay in a fresh process.

Uses the published Republic 0.6.0a1 preview from PyPI, including native audio input and the republic.tool(...) message API.

Validation:

  • 599 tests passed, 1 skipped, with doctests and the tracing extra enabled.
  • make check: lock validation, all-file prek and mypy passed (56 source files).
  • English/Chinese website build and uv build passed.
  • Provider behavior is verified with HTTP transports; live model generation was not run.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
bub 80ca6c0 Commit Preview URL

Branch Preview URL
Oct 13 2026, 12:54 AM

@PsiACE PsiACE changed the title refactor: replace any-llm and builtin Codex OAuth with Republic refactor: use Republic for builtin models and account authentication Oct 9, 2026
@PsiACE
PsiACE force-pushed the refactor/republic-provider-migration branch 4 times, most recently from 4f5ba07 to 2426720 Compare October 9, 2026 17:21
Comment thread pyproject.toml Outdated
Comment thread src/bub/builtin/onboarding.py
Comment thread src/bub/builtin/onboarding.py Outdated
@frostming
frostming marked this pull request as ready for review October 10, 2026 07:32
PsiACE and others added 8 commits October 13, 2026 08:32
- Introduced `republic` module to manage media types and user content.
- Updated tests to validate new prompt structure and legacy content conversion.
- Modified `build_prompt` to return a list of `UserContent` instead of legacy formats.
- Enhanced documentation to reflect changes in prompt handling and hook signatures.
- Adjusted various tests to ensure compatibility with new prompt formats and legacy support.

Signed-off-by: Frost Ming <me@frostming.com>
Older Bub versions recorded tool calls as
{"id", "type": "function", "function": {"name", "arguments"}}, which
republic.Message.from_dict rejects with KeyError: 'name', so sessions
with such tapes could not build their context. Convert them to
Republic's form in to_message, next to the other legacy conversions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Send User-Agent: bub/{version} instead of Republic's default through
AgentSettings.model_client_kwargs, used by the model runner, code mode
and onboarding. A User-Agent in client_args.headers still wins.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@frostming
frostming force-pushed the refactor/republic-provider-migration branch from 39158a3 to 8bd469e Compare October 13, 2026 00:32
@frostming
frostming removed this pull request from stack #352 October 13, 2026 00:53
- Add a stdlib `republic` module to run_code: media classes, messages,
  get_model() (chat and stream), get_embedding_model() and
  get_decision_model(). Model calls are proxied to Bub, which uses its
  provider settings and credentials; they never reach the code.
- Add code-only tools attach_image/attach_audio/attach_video that accept
  republic media or a path/URL/data URL and attach it to the run_code
  result, sent to the model as a multimodal tool message.
- Add content results (bub.tools.content_result) for tool results with
  media; spilling bounds only their text.
- Add Environment.read_bytes with a default that runs the environment's
  python.
- Document the republic module in the code mode stub and prompt.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@frostming
frostming changed the base branch from main to dev October 13, 2026 00:55
@frostming
frostming merged commit d89fb03 into dev Oct 13, 2026
6 checks passed
@frostming
frostming deleted the refactor/republic-provider-migration branch October 13, 2026 00:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants