Skip to content

feat(builder): run codegen + preview on any configured LLM provider (#297)#320

Open
MarvinVomberg wants to merge 3 commits into
byte5ai:mainfrom
MarvinVomberg:feat/builder-multi-provider
Open

feat(builder): run codegen + preview on any configured LLM provider (#297)#320
MarvinVomberg wants to merge 3 commits into
byte5ai:mainfrom
MarvinVomberg:feat/builder-multi-provider

Conversation

@MarvinVomberg

Copy link
Copy Markdown

Closes #297.

Summary

Makes the Agent Builder provider-agnostic. The Builder was the last place still hard-locked to Anthropic: modelRegistry.ts rejected any non-Anthropic registry entry, and both the builder agent loop and the preview chat constructed an Anthropic provider at the call site. Building on the pluggable provider registry (#298) and per-instance orchestrator models (#296), this lets a draft run codegen and preview on any model whose provider the operator has configured.

Changes

  • modelRegistry: removes the Anthropic-only guard; sources models from the global @omadia/llm-provider registry. New resolve(ref) → { provider, modelId } throws a clear, actionable error for an unregistered reference. Anthropic slugs stay as the default and as a pre-boot fallback.
  • types / draftStore: BuilderModelId is now any registry reference (provider-qualified id or legacy slug). The stored value is preserved as-is rather than coerced to a default, so a draft pinned to a removed provider fails loudly at run time instead of being silently reset.
  • builderAgent + previewChatService: the anthropic: () => AnthropicClient dependency is replaced by a resolveProvider seam. The LocalSubAgent is built from the resolved LlmProvider + bare vendor id. Resolution happens per turn, so a hot-swapped key (Setup Wizard / admin secrets) is picked up without a restart.
  • index.ts: resolveBuilderProvider wires the Anthropic fast-path (shared hot-swappable client) plus the generic resolveLlmProvider path (vault scope + provider catalog). builderConnectedProviders feeds the picker so only providers with a configured API key (or keyless providers like Ollama) are selectable.
  • routes: GET /models lists models from every connected provider; builderChat / builderPreview validate against the registry and pass the reference through; builderPreviewPrompt resolves the reference for persona-family inference.
  • web-ui: the Codegen/Preview model picker is populated from /models, grouped per provider (<optgroup>), instead of the fixed haiku | sonnet | opus set.

Acceptance criteria (#297)

  • A draft can run codegen and preview on a non-Anthropic model when that provider is configured.
  • The Anthropic-only guard in modelRegistry.ts is gone; no code path assumes the Builder model is Anthropic.
  • The picker lists models from every configured provider, not a fixed three-slug set (and hides providers without a key).
  • New drafts default to an Anthropic model; existing drafts keep their stored choice.
  • A draft referencing an unregistered model fails with a clear, actionable error.

Testing

  • npm run typecheck (middleware + web-ui) clean.
  • Full middleware suite: 3425 pass / 0 fail. Builder tests migrated to the new resolveProvider seam.
  • ESLint clean on all changed files.
  • Manual smoke-check in a local container stack: a draft whose stored codegen_model was mistral:mistral-large-latest completed its builder-chat turns, while drafts left on the Anthropic default returned a 401 from an invalid local Anthropic key. Reviewers should run their own end-to-end check with valid provider keys.

🤖 Generated with Claude Code

MarvinVomberg and others added 3 commits June 16, 2026 14:35
…yte5ai#297)

The Agent Builder was hard-locked to Anthropic: the model resolver rejected
non-Anthropic registry entries and both the builder agent loop and preview
chat constructed an Anthropic provider at the call site. With the pluggable
provider work merged (byte5ai#298) and per-instance orchestrator models (byte5ai#296), this
lifts the last restriction.

- modelRegistry: drop the Anthropic-only guard; source models from the global
  @omadia/llm-provider registry. Add resolve(ref) -> {provider, modelId} that
  throws an actionable error for an unregistered reference. Anthropic slugs
  stay as the default + a pre-boot fallback.
- types/draftStore: BuilderModelId is now any registry reference (provider-
  qualified id or legacy slug); stored value is preserved, not coerced.
- builderAgent + previewChatService: replace the anthropic-client dep with a
  resolveProvider seam; the LocalSubAgent is built from the resolved
  LlmProvider + bare vendor id. Re-resolved per turn (hot-swap safe).
- index.ts: resolveBuilderProvider wires the Anthropic fast-path + the generic
  resolveLlmProvider path (vault scope + provider catalog). builderConnectedProviders
  feeds the picker so only providers with a configured key (or keyless ones)
  are selectable.
- routes: /models lists models from every connected provider; chat/preview
  validate against the registry and pass the reference; preview-prompt resolves
  the reference for family inference.
- web-ui: model picker is populated from /models, grouped per provider, instead
  of the fixed haiku|sonnet|opus set.

New drafts still default to Anthropic; existing drafts keep their stored choice.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- modelRegistry/types/routes: surface model aliases so the codegen/preview
  picker maps a legacy slug value onto its canonical provider-qualified
  option (no duplicate option, no raw lowercase label); default stays the slug
- previewChatService: yield a graceful builder.model_unavailable on provider
  resolution failure, mirroring builderAgent, instead of throwing raw
- routes/builder: wrap GET /models in try/catch like its sibling routes
- index: parallelize builderConnectedProviders key lookups; rename
  ANTHROPIC_SHARED_CLIENT_SOURCE -> ORCHESTRATOR_SECRET_SOURCE (provider-neutral)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…provider

# Conflicts:
#	middleware/src/index.ts
#	middleware/src/plugins/builder/builderAgent.ts
#	middleware/src/plugins/builder/previewChatService.ts
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.

Adapt the Agent Builder to use different LLM providers

1 participant