feat(ai-gateway): add organization auto model routing#4056
Conversation
|
|
||
| const directByokTarget = await getDirectByokModel(rawModelId); | ||
| if (directByokTarget.provider && directByokTarget.model) { | ||
| const byok = await getBYOKforOrganization(db, organization.id, [directByokTarget.provider.id]); |
There was a problem hiding this comment.
WARNING: getBYOKforOrganization(db, ...) uses the module-level db instance instead of a transaction-aware connection.
When validateOrganizationAutoTarget is called inside a mutateOrganizationSettings callback (which runs within a FOR UPDATE transaction on the organizations row), the BYOK credential read at this line executes on a different database session, outside the transaction's isolation context. A concurrent BYOK credential modification by another request could yield a stale read between the transaction lock and the BYOK check.
Consider accepting an optional DrizzleTransaction parameter so that callers inside transactions can pass tx for consistency.
Reply with @kilocode-bot fix it to have Kilo Code address this issue.
Code Review SummaryStatus: 1 Issue Found | Recommendation: Address before merge Executive Summary
Overview
Issue Details (click to expand)WARNING
Files Reviewed (41 files)
Fix these issues in Kilo Cloud Reviewed by deepseek-v4-pro-20260423 · 1,742,068 tokens Review guidance: REVIEW.md from base branch |
Summary
kilo-auto/org, an Enterprise-only Organization Auto model that lets an organization choose which model should handle each Kilo mode.organizations.settings.org_auto_model:buildusesroutes.buildbefore falling back toroutes.code, andplanusesroutes.planbefore falling back toroutes.architect.org-default-model-configmode-default rollout with the neworganization-auto-model-routingPostHog toggle for canonical organization-wide routing.OrganizationModeConfig.defaultModelbridge and stores all routing only inorganizations.settings.org_auto_model.Verification
/tmp/org-auto-api-log.shagainst a local service, including modes/defaults/models and optional gateway requests.Visual Changes
Reviewer Notes
org_auto_modelsettings, gateway resolution, BYOK ownership checks, route lifecycle consistency, and UI configuration.organization-auto-model-routing, replacing the oldorg-default-model-configtoggle. Runtime routing remains data-driven for already-configured organizations, and disable remains available during rollback.organization-auto-model-shared.tsexists specifically to keep client components from importing server-only DB/pg code.