From 1ac6f9118718e5fcc10efee5a3fd4cfbac87e7b8 Mon Sep 17 00:00:00 2001 From: Brendan O'Leary Date: Fri, 6 Mar 2026 16:19:00 -0500 Subject: [PATCH] Send feature details to abuse classifier --- src/app/api/openrouter/[...path]/route.ts | 11 +++++++---- src/lib/abuse-service.ts | 4 ++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/app/api/openrouter/[...path]/route.ts b/src/app/api/openrouter/[...path]/route.ts index f383a6411..43690d0a7 100644 --- a/src/app/api/openrouter/[...path]/route.ts +++ b/src/app/api/openrouter/[...path]/route.ts @@ -234,6 +234,11 @@ export async function POST(request: NextRequest): Promise 0, botId, tokenSource, - feature: validateFeatureHeader( - request.headers.get(FEATURE_HEADER) || (isLegacyOpenRouterPath ? '' : 'direct-gateway') - ), + feature, session_id: taskId ?? null, mode: modeHeader, auto_model: autoModel, diff --git a/src/lib/abuse-service.ts b/src/lib/abuse-service.ts index e7e00147b..adc7e0127 100644 --- a/src/lib/abuse-service.ts +++ b/src/lib/abuse-service.ts @@ -11,6 +11,7 @@ import { import { getFraudDetectionHeaders } from '@/lib/utils'; import type { OpenRouterChatCompletionRequest } from '@/lib/providers/openrouter/types'; import type { AuthProviderId } from '@/lib/auth/provider-metadata'; +import type { FeatureValue } from '@/lib/feature-detection'; import 'server-only'; /** @@ -183,6 +184,7 @@ export type UsagePayload = { is_byok?: boolean | null; is_user_byok?: boolean | null; editor_name?: string | null; + feature?: string | null; // Existing classification (if any) abuse_classification?: number | null; @@ -332,6 +334,7 @@ export type AbuseClassificationContext = { projectId?: string | null; provider?: string | null; isByok?: boolean | null; + feature?: FeatureValue | null; }; /** @@ -372,6 +375,7 @@ export async function classifyAbuse( streamed: body.stream === true, is_user_byok: context?.isByok ?? null, editor_name: request.headers.get('x-kilocode-editorname') ?? null, + feature: context?.feature ?? null, }; return classifyRequest(payload);