Skip to content

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

Draft
PsiACE wants to merge 5 commits into
mainfrom
refactor/republic-provider-migration
Draft

PsiACE wants to merge 5 commits into
mainfrom
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 fd824a0 Commit Preview URL

Branch Preview URL
Oct 10 2026, 05:16 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 from c40a64d to fbdbb03 Compare October 9, 2026 16:48
@PsiACE
PsiACE force-pushed the refactor/republic-provider-migration branch 2 times, most recently from 50b6c6d to 4f5ba07 Compare October 9, 2026 17:12
@PsiACE
PsiACE force-pushed the refactor/republic-provider-migration branch from 4f5ba07 to 2426720 Compare October 9, 2026 17:21
Comment thread pyproject.toml Outdated
"typer>=0.24.1",
"authlib>=1.7.2",
"any-llm-sdk[anthropic]>=1.22.1",
"republic @ git+https://github.com/bubbuild/republic.git@449debdfed5b45dffb4744091db84fbbeb0704b7",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can cut a preview release before we process this.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😘 and we should give bub a new release

"mistral": "Mistral AI",
"deepseek": "DeepSeek",
"custom": "Other provider (SDK provider name)",
"custom": "Other registered Republic provider",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add magpie since republic natively supports it.

Comment thread src/bub/builtin/onboarding.py Outdated
result = close()
if inspect.isawaitable(result):
await result
client = republic.get_provider(provider, **client_args)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use an async context manager, it is landed in republic lately

This branch has not been deployed

No deployments
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