Skip to content

refactor: provider and selection strategy - #1264

Merged
woorui merged 6 commits into
mainfrom
refactor/provider
Aug 12, 2026
Merged

refactor: provider and selection strategy#1264
woorui merged 6 commits into
mainfrom
refactor/provider

Conversation

@woorui

@woorui woorui commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

What this PR does

This PR refactors provider management by introducing a unified provider registry shared by both Chat Completions and Model API routes.

Previously, provider selection logic was split between llm_provider and model_api_provider. This change consolidates selection, endpoint capability checks, and provider construction into a single provider_registry module.

Key changes

  • Added a new unified registry: src/provider_registry.rs

    • Centralizes provider catalog building and endpoint-aware model selection.
    • Introduces endpoint-scoped selection via EndpointKind.
    • Supports custom chat/endpoint provider builders through extension hooks.
    • Preserves provider error notification wrapping.
  • Removed duplicated registries/selection modules:

    • src/llm_provider/registry.rs
    • src/llm_provider/selection.rs
    • src/model_api_provider/registry.rs
    • src/model_api_provider/selection.rs
  • Updated API layers to use the unified registry:

    • src/llm_api.rs now calls select_chat(...).
    • src/model_api.rs now calls select_endpoint(...).
    • Selection error handling now returns endpoint-specific messages:
      • model is required for /v1/...
      • model <x> is not supported for /v1/...
  • Unified /v1/models source:

    • src/model_list.rs now reads from one registry instead of merging two registries.
  • Simplified server boot wiring:

    • src/bin/yomo.rs now initializes one registry and shares it across:
      • LLM API
      • Model API
      • Model List API

Config and behavior updates

  • ServeConfig has been simplified and unified:

    • Replaces separate llm_providers + llm_default_model_id + model_api.*
    • Uses:
      • providers: Vec<ProviderConfig>
      • endpoints: Vec<EndpointConfig>
  • Added shared endpoint abstraction in serve_config:

    • EndpointKind
    • parse_generate_content_model(...)
    • endpoint path validation and parsing
  • Provider type routing is now endpoint-capability driven.

    • Endpoint clients no longer enforce legacy endpoint-specific provider type names like "messages", "responses", "passthrough".
    • anthropic-messages / bedrock-messages naming is used consistently.

Tests

Added/updated unit tests for:

  • endpoint-default selection behavior
  • custom builder integration
  • unsupported provider type rejection per endpoint
  • duplicate endpoint path rejection
  • endpoint capability enforcement
  • model list filtering to endpoint-enabled models
  • endpoint-aware selection error message formatting

@woorui woorui self-assigned this Aug 10, 2026
@codecov

codecov Bot commented Aug 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 67.02002% with 280 lines in your changes missing coverage. Please review.
✅ Project coverage is 65.12%. Comparing base (a4168f2) to head (330ce99).

Files with missing lines Patch % Lines
src/provider_registry.rs 77.01% 157 Missing ⚠️
src/serve_config.rs 20.73% 65 Missing ⚠️
src/bin/yomo.rs 0.00% 24 Missing ⚠️
src/llm_api.rs 42.42% 19 Missing ⚠️
src/model_api.rs 50.00% 12 Missing ⚠️
src/model_list.rs 0.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1264      +/-   ##
==========================================
+ Coverage   63.63%   65.12%   +1.48%     
==========================================
  Files          49       47       -2     
  Lines       12326    12400      +74     
==========================================
+ Hits         7844     8075     +231     
+ Misses       4482     4325     -157     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@fanweixiao fanweixiao left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

💯

@woorui
woorui merged commit df6d756 into main Aug 12, 2026
6 checks passed
@woorui
woorui deleted the refactor/provider branch August 12, 2026 16:34
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