Skip to content

Commit b1aa4b2

Browse files
VKirillclaude
andcommitted
VK experimental: BB_INFERENCE_SERVICE_TIER runs helper inference on the fast tier
Titles and thread metadata can use Codex's Fast tier: the setting travels through the AI-service contract as serviceTier, and the Codex service sends service_tier=priority, the id Codex lists for Fast. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
1 parent c35ee0a commit b1aa4b2

8 files changed

Lines changed: 72 additions & 0 deletions

File tree

‎apps/server/src/services/ai/inference.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,10 @@ async function completeWithAiService<T extends TSchema>(
261261
serviceId: service.id,
262262
model: modelInfo.modelId,
263263
reasoningEffort: "none",
264+
// VK EXPERIMENTAL: the user's service tier for helper inference.
265+
...(deps.config.inferenceServiceTier === "fast"
266+
? { serviceTier: "fast" as const }
267+
: {}),
264268
prompt: args.prompt,
265269
outputSchema: jsonObjectSchema.parse(args.schema),
266270
timeoutMs,

‎apps/server/src/services/system/bb-app-managed-config.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,11 @@ export function applyBbAppManagedConfig(
113113
managedConfig.BB_INFERENCE_FALLBACK !== undefined
114114
? validateInferenceFallbackModel(managedConfig.BB_INFERENCE_FALLBACK)
115115
: args.baseConfig.inferenceFallbackModel;
116+
// VK EXPERIMENTAL: service tier for helper inference.
117+
args.targetConfig.inferenceServiceTier =
118+
managedConfig.BB_INFERENCE_SERVICE_TIER ??
119+
args.baseConfig.inferenceServiceTier ??
120+
null;
116121
args.targetConfig.transcriptionModel =
117122
managedConfig.BB_TRANSCRIPTION !== undefined
118123
? validateTranscriptionModel(managedConfig.BB_TRANSCRIPTION)

‎apps/server/src/start-server.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ export async function runServer(serverConfig: ServerConfig): Promise<void> {
150150
inheritedSkillsRootPaths: serverConfig.BB_INHERITED_SKILLS_ROOTS,
151151
inferenceFallbackModel: serverConfig.BB_INFERENCE_FALLBACK,
152152
inferenceModel: serverConfig.BB_INFERENCE,
153+
inferenceServiceTier: null,
153154
isDevelopment: !isProduction,
154155
openAiApiKey: serverConfig.OPENAI_API_KEY,
155156
serverPort: serverConfig.BB_SERVER_PORT,

‎apps/server/src/types.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ export interface ServerRuntimeConfig {
3131
inheritedSkillsRootPaths: string[];
3232
inferenceFallbackModel: string;
3333
inferenceModel: string;
34+
/** VK EXPERIMENTAL: service tier for helper inference; null = default. */
35+
inferenceServiceTier?: "fast" | "default" | null;
3436
isDevelopment: boolean;
3537
marketplaceUrl: string;
3638
openAiApiKey: string;

‎packages/config/src/bb-app-managed-config.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,15 @@ export type BbAppManagedConfigKey =
2424
| "BB_APP_URL"
2525
| "BB_INFERENCE"
2626
| "BB_INFERENCE_FALLBACK"
27+
| "BB_INFERENCE_SERVICE_TIER"
2728
| "BB_LOG_LEVEL"
2829
| "BB_TRANSCRIPTION";
2930

3031
export const BB_APP_MANAGED_CONFIG_KEYS: BbAppManagedConfigKey[] = [
3132
"BB_APP_URL",
3233
"BB_INFERENCE",
3334
"BB_INFERENCE_FALLBACK",
35+
"BB_INFERENCE_SERVICE_TIER",
3436
"BB_LOG_LEVEL",
3537
"BB_TRANSCRIPTION",
3638
];
@@ -52,6 +54,8 @@ const bbAppManagedConfigValuesSchema = z
5254
BB_APP_URL: z.string().optional(),
5355
BB_INFERENCE: z.string().optional(),
5456
BB_INFERENCE_FALLBACK: z.string().optional(),
57+
// VK EXPERIMENTAL: service tier for helper inference (titles, metadata).
58+
BB_INFERENCE_SERVICE_TIER: z.enum(["fast", "default"]).optional(),
5559
BB_LOG_LEVEL: z.string().optional(),
5660
BB_TRANSCRIPTION: z.string().optional(),
5761
})

‎packages/plugin-sdk/src/ai-services.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@ export const experimental_aiInferenceCompleteInputSchema = z
5555
model: z.string().min(1),
5656
/** Helper inference is short and latency-bound; no reasoning. */
5757
reasoningEffort: z.literal("none"),
58+
/**
59+
* VK EXPERIMENTAL — the service tier the user chose for helper inference
60+
* (`BB_INFERENCE_SERVICE_TIER`). `fast` asks the service for its priority
61+
* tier where it has one; a service without tiers ignores it.
62+
*/
63+
serviceTier: z.enum(["fast", "default"]).optional(),
5864
prompt: z.string().min(1),
5965
/** A JSON Schema object the structured result must satisfy. */
6066
outputSchema: jsonObjectSchema,

‎plugins/provider-codex/src/ai/chatgpt-client.test.ts‎

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,51 @@ describe("Codex ChatGPT client", () => {
312312
});
313313
});
314314

315+
it("asks for the priority tier when helper inference runs fast", async () => {
316+
const homeDir = await makeTempHome();
317+
const accessToken = createAccessToken({
318+
accountId: "account-123",
319+
expSeconds: Math.floor(Date.now() / 1000) + 3600,
320+
});
321+
await writeCodexAuth({
322+
homeDir,
323+
accessToken,
324+
refreshToken: "refresh-token",
325+
});
326+
const fetchMock = setupFetchMock();
327+
const titleEvent = {
328+
type: "response.output_text.delta",
329+
delta: '{"title":"Short title"}',
330+
};
331+
fetchMock
332+
.mockResolvedValueOnce(sseResponse([titleEvent]))
333+
.mockResolvedValueOnce(sseResponse([titleEvent]));
334+
const command = {
335+
serviceId: "codex",
336+
model: "gpt-6-luna",
337+
reasoningEffort: "none" as const,
338+
prompt: "Return a title",
339+
outputSchema: {
340+
type: "object",
341+
additionalProperties: false,
342+
properties: { title: { type: "string" } },
343+
},
344+
timeoutMs: 10000,
345+
};
346+
347+
await completeCodexInference({ ...command, serviceTier: "fast" });
348+
await completeCodexInference(command);
349+
350+
const [, fastInit] = requiredFetchCall(fetchMock, 0);
351+
expect(JSON.parse(textBodyFromInit(fastInit)).service_tier).toBe(
352+
"priority",
353+
);
354+
const [, defaultInit] = requiredFetchCall(fetchMock, 1);
355+
expect(
356+
JSON.parse(textBodyFromInit(defaultInit)).service_tier,
357+
).toBeUndefined();
358+
});
359+
315360
it("runs structured inference with Codex API key auth from ~/.codex/auth.json", async () => {
316361
const homeDir = await makeTempHome();
317362
await writeCodexApiKeyAuth({

‎plugins/provider-codex/src/ai/chatgpt-client.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ interface CodexResponsesRequest {
120120
};
121121
store: boolean;
122122
stream: boolean;
123+
/** VK EXPERIMENTAL: `priority` is what Codex's "fast" tier sends. */
124+
service_tier?: "priority";
123125
input: CodexInputMessage[];
124126
text: {
125127
format: CodexResponseFormat;
@@ -706,6 +708,9 @@ function buildCodexResponsesRequest(
706708
reasoning: { effort: command.reasoningEffort },
707709
store: false,
708710
stream: true,
711+
...(command.serviceTier === "fast"
712+
? { service_tier: "priority" as const }
713+
: {}),
709714
input: [
710715
{
711716
role: "user",

0 commit comments

Comments
 (0)