feat(models): expose auto-routing choices in models API#4396
Conversation
3fada81 to
aca83ed
Compare
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Executive SummaryReviewed the incremental changes that extend the filter/enrich reordering fix to the organization models route, adding Files Reviewed (3 files)
Previous Review Summary (commit aca83ed)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit aca83ed)Status: No Issues Found | Recommendation: Merge Executive SummaryReviewed the auto-routing enrichment refactor and the filter/enrich reordering across both model-listing paths (org and public/BYOK); the fix that runs Files Reviewed (4 files)
Reviewed by claude-sonnet-5 · Input: 34 · Output: 9.3K · Cached: 752.6K Review guidance: REVIEW.md from base branch |
|
My guess is you also have to add these changes here for the organization-specific endpoint: but wouldn't it make more sense to add the extra metadata the first time the auto model definitions are created? |
Annotate the virtual kilo-auto/efficient and kilo-auto/free models with their concrete candidate ids (autoRouting.models) in the models API responses, so the model selector can show what auto-routing picks among. Applied on /api/openrouter/models (org and public/BYOK paths) and on /api/organizations/[id]/models — the endpoint the extension uses for organization catalogs, where the choices were originally missing. Candidates are filtered to models available to the caller: enrichment runs after org restrictions and feature filtering, so a deny-listed or feature-excluded model never surfaces as a routing choice. The benchmark routing table is cached in-process (5-min, stale-on-error) so it is not a per-request round-trip and a transient worker outage does not blank the choices. Adds unit coverage for addAutoRoutingModels and first direct test coverage for getAvailableModelsForOrganization.
aca83ed to
e377f87
Compare
|
Good catch, added to the organization endpoint too (that was the original point, but missed after refactoring). On the second part, I looked into it and there's an issue: org/feature filtering happens later and only drops top-level model ids - it doesn't touch the nested autoRouting.models. Adding the choices at definition time would let the org endpoint list candidates that were filtered out for that org (deny-listed models would show up as choices routing can never pick). Added a test locking this invariant in. Let me know if I am missing something. |
Summary
Expose the concrete models behind the virtual Auto Efficient (
kilo-auto/efficient) and Auto Free (kilo-auto/free) routing choices in the/api/openrouter/modelsresponse, so the model selector can show which models auto-routing picks among.addAutoRoutingModels(), which annotates the auto models withautoRouting.models— the concrete candidate ids from the benchmark routing table (efficient) and free-model resolution (free), intersected with the models actually available to the caller.getAvailableModelsForOrganization) and public/BYOK (route handler).createCachedFetch), so it is not an uncached admin-worker round-trip per request and a transient worker outage does not blank the choices.getAvailableModelsForOrganization(previously only ever mocked).This is the server-side counterpart that lets us drop the client-side merge fallback in
kilo-gateway.Verification
Ran local web (
pnpm dev) against a docker Redis seeded via/api/cron/sync-providers(935-model catalog), with a mock benchmark routing table served on the local worker port, same approach as #4274.{ "id": "kilo-auto/efficient", "autoRouting": { "models": ["anthropic/claude-opus-4.8", "openai/gpt-5.5"] } } { "id": "kilo-auto/free", "autoRouting": { "models": ["stepfun/step-3.7-flash:free"] } }Visual Changes
N/A - server-side API change; the model-selector rendering already lives on
mainin the extension.Reviewer Notes