Repository navigation
fix(byok): show BYOK only for keys a shared-services run can use - #7819
Conversation
Model pickers for runs the platform makes for an organization (code review, auto-fix, auto-triage, webhook triggers, Discord bot) badged models BYOK from the viewing member's personal ChatGPT connection. The gateway never uses that connection for a service run, so those runs were billed by Kilo. The organization model list now takes an audience. A shared_services list tags ChatGPT models only from the organization's shared-services connection; organization BYOK keys tag as before. Members' own pickers keep the member list. Web and mobile pickers for service runs request the shared_services list.
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Executive SummaryThe incremental changes only make the tRPC Files Reviewed (3 files)
Notes: verified Previous Review Summary (commit 1ecc142)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit 1ecc142)Status: No Issues Found | Recommendation: Merge Executive SummaryThe new Files Reviewed (25 files)
Notes: Reviewed by deepseek-v4.1-flash · Input: 31.5K · Output: 4.5K · Cached: 309.4K Review guidance: REVIEW.md from base branch |


Problem
The Code Reviewer model picker showed an OpenAI model as BYOK when one organization member had connected their own ChatGPT account. A review runs as the organization's bot, and the gateway serves a bot run from the organization's shared-services ChatGPT connection only (
openai-chatgpt/routing.ts,openAiChatGptOwnerCandidates). It never uses a member's own connection. The review then fell back to Kilo-billed routing, and the customer was charged for reviews they believed were BYOK. The same wrong badge appeared in every picker whose model a platform service runs for the organization.Fix
getAvailableModelsForOrganizationandorganizations.settings.listAvailableModelstake an optionalaudience:member(the default) orshared_services. Ashared_serviceslist tags ChatGPT-served models only fromopenAiChatGptSharedServicesOwner(organizationId). Organization BYOK API keys tag as before.GET /api/organizations/{id}/models?audience=shared_servicespasses it through and rejects an unknown value with 400.@kilocode/app-shared/organizations(ORGANIZATION_MODEL_AUDIENCES,organizationModelsPath). Web and mobile use it to build the URL.Pickers switched to
shared_servicesEach one configures a run whose gateway token carries a bot id and an organization:
ReviewConfigFormplatform-overview-screenBitbucketReviewConfigFormbitbucket-overviewCodeReviewJobsCardmanual-review-screenAutoFixConfigFormAutoTriageConfigFormCreateWebhookTriggerContent,EditWebhookTriggerContentDiscordIntegrationDetailsMobile requests the list through the new
useReviewerModels(scope)hook. Mobile computes no badge of its own: it renders the server'shasUserByokAvailable.Deliberately unchanged
/api/openrouter/models). The badge was already correct there.Verification
organization-models.test.ts: a new regression test. A member-only ChatGPT connection tags the model in the member list but not in the shared-services list. A shared-services connection tags it in the shared-services list. Organization BYOK keys still tag the shared-services list. With the producer change stashed, the test fails.handlers/organization-models.test.ts: the audience query parameter reaches the catalog, and an unknown value returns 400.app-shared,web-shared,web,ai-gatewayandmobile. Mobile lint andcheck:unusedpass, and the mobilecode-reviewerandhookssuites pass.openai/gpt-5.6-terraBYOK, but the shared-services list does not, and the Code Reviewer picker shows no BYOK badge. A request made with the review bot's token goes to the Kilo-billed route, and the stub receives nothing.openai-chatgpt.