@vellumai/assistant 0.12.0-dev.202609122213.71fcf45 → 0.12.0-dev.202609131222.988a33e
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/__tests__/model-intents.test.ts +3 -0
- package/src/config/__tests__/default-profile-catalog.test.ts +22 -0
- package/src/providers/model-catalog.ts +4 -2
- package/src/providers/model-intents.ts +10 -5
- package/src/providers/openai/__tests__/chat-completions-provider-reasoning.test.ts +102 -19
- package/src/providers/openai/chat-completions-provider.ts +5 -3
package/package.json
CHANGED
|
@@ -28,6 +28,9 @@ describe("model intents", () => {
|
|
|
28
28
|
expect(resolveModelIntent("openai", "latency-optimized")).toBe(
|
|
29
29
|
"gpt-5.6-luna",
|
|
30
30
|
);
|
|
31
|
+
expect(resolveModelIntent("gemini", "cost-optimized")).toBe(
|
|
32
|
+
"gemini-3.1-flash-lite",
|
|
33
|
+
);
|
|
31
34
|
expect(resolveModelIntent("gemini", "latency-optimized")).toBe(
|
|
32
35
|
"gemini-3.1-flash-lite",
|
|
33
36
|
);
|
|
@@ -540,6 +540,28 @@ describe("resolveDefaultProfileForProvider", () => {
|
|
|
540
540
|
expect(entry).toBe(workspace.balanced);
|
|
541
541
|
});
|
|
542
542
|
|
|
543
|
+
// Google limits gemini-2.5-flash-lite to grandfathered accounts (other API
|
|
544
|
+
// keys get HTTP 404 "no longer available to new users"), so a default
|
|
545
|
+
// profile resolving to it lists as available and fails every request on a
|
|
546
|
+
// fresh BYOK key.
|
|
547
|
+
test("gemini BYOK defaults never resolve to a model Google refuses new keys", () => {
|
|
548
|
+
const budget = resolveDefaultProfileForProvider(
|
|
549
|
+
managedStubs(),
|
|
550
|
+
"cost-optimized",
|
|
551
|
+
dp("gemini"),
|
|
552
|
+
);
|
|
553
|
+
expect(budget?.provider).toBe("gemini");
|
|
554
|
+
expect(budget?.model).toBe("gemini-3.1-flash-lite");
|
|
555
|
+
for (const key of DEFAULT_PROFILE_KEYS) {
|
|
556
|
+
const entry = resolveDefaultProfileForProvider(
|
|
557
|
+
managedStubs(),
|
|
558
|
+
key,
|
|
559
|
+
dp("gemini"),
|
|
560
|
+
);
|
|
561
|
+
expect(entry?.model).not.toBe("gemini-2.5-flash-lite");
|
|
562
|
+
}
|
|
563
|
+
});
|
|
564
|
+
|
|
543
565
|
test("a managed-source stub contributes only label/status/topP over the provider-resolved body", () => {
|
|
544
566
|
const workspace: Record<string, ProfileEntry> = {
|
|
545
567
|
balanced: {
|
|
@@ -863,6 +863,9 @@ const RAW_PROVIDER_CATALOG: ProviderCatalogEntry[] = [
|
|
|
863
863
|
cacheReadPer1mTokens: 0.03,
|
|
864
864
|
},
|
|
865
865
|
},
|
|
866
|
+
// Limited to grandfathered accounts: other API keys get HTTP 404 "no
|
|
867
|
+
// longer available to new users", so this model is user-selectable
|
|
868
|
+
// only and no intent column may resolve to it.
|
|
866
869
|
{
|
|
867
870
|
id: "gemini-2.5-flash-lite",
|
|
868
871
|
displayName: "Gemini 2.5 Flash Lite",
|
|
@@ -2655,8 +2658,7 @@ export function supportsForcedToolChoiceWithThinking(
|
|
|
2655
2658
|
return !provider.models.some(
|
|
2656
2659
|
(model) =>
|
|
2657
2660
|
model.supportsForcedToolChoiceWithThinking === false &&
|
|
2658
|
-
(model.id === modelId ||
|
|
2659
|
-
stripDateSuffix(model.id) === normalizedModelId),
|
|
2661
|
+
(model.id === modelId || stripDateSuffix(model.id) === normalizedModelId),
|
|
2660
2662
|
);
|
|
2661
2663
|
}
|
|
2662
2664
|
|
|
@@ -11,10 +11,15 @@ const PROVIDER_DEFAULT_MODELS: Record<string, string> = Object.fromEntries(
|
|
|
11
11
|
);
|
|
12
12
|
|
|
13
13
|
// `cost-optimized` is the cheapest model a provider serves, `latency-optimized`
|
|
14
|
-
// the fastest to first token. On anthropic, ollama, fireworks
|
|
15
|
-
// same model is both, so those columns repeat by construction
|
|
16
|
-
// oversight (openai's balanced repeats it too: the
|
|
17
|
-
// split those tiers by reasoning effort, not model).
|
|
14
|
+
// the fastest to first token. On anthropic, ollama, fireworks, openai and
|
|
15
|
+
// gemini the same model is both, so those columns repeat by construction
|
|
16
|
+
// rather than by oversight (openai's balanced repeats it too: the
|
|
17
|
+
// default-profile templates split those tiers by reasoning effort, not model).
|
|
18
|
+
//
|
|
19
|
+
// "Serves" means serves to every API key: Google's `gemini-2.5-flash-lite`
|
|
20
|
+
// undercuts every 3.x Flash-Lite but is limited to grandfathered accounts
|
|
21
|
+
// (other keys get HTTP 404 "no longer available to new users"), so the
|
|
22
|
+
// gemini column skips it.
|
|
18
23
|
const PROVIDER_MODEL_INTENTS: Record<string, Record<ModelIntent, string>> = {
|
|
19
24
|
anthropic: {
|
|
20
25
|
balanced: "claude-sonnet-4-6",
|
|
@@ -32,7 +37,7 @@ const PROVIDER_MODEL_INTENTS: Record<string, Record<ModelIntent, string>> = {
|
|
|
32
37
|
},
|
|
33
38
|
gemini: {
|
|
34
39
|
balanced: "gemini-3-flash-preview",
|
|
35
|
-
"cost-optimized": "gemini-
|
|
40
|
+
"cost-optimized": "gemini-3.1-flash-lite",
|
|
36
41
|
"latency-optimized": "gemini-3.1-flash-lite",
|
|
37
42
|
"quality-optimized": "gemini-3.1-pro-preview",
|
|
38
43
|
"vision-optimized": "gemini-3-flash-preview",
|
|
@@ -936,7 +936,11 @@ describe("thinking-mode tool_choice rejection fallback", () => {
|
|
|
936
936
|
|
|
937
937
|
test("retries once when Kimi rejects a specified tool_choice in thinking mode", async () => {
|
|
938
938
|
const { provider, requests } = stubProviderWithErrors(
|
|
939
|
-
[
|
|
939
|
+
[
|
|
940
|
+
rejection(
|
|
941
|
+
"tool_choice 'specified' is incompatible with thinking enabled",
|
|
942
|
+
),
|
|
943
|
+
],
|
|
940
944
|
OK_CHUNKS,
|
|
941
945
|
);
|
|
942
946
|
|
|
@@ -1186,33 +1190,80 @@ describe("unknown assistant reasoning field rejection fallback", () => {
|
|
|
1186
1190
|
},
|
|
1187
1191
|
];
|
|
1188
1192
|
|
|
1189
|
-
test(
|
|
1193
|
+
test.each([
|
|
1194
|
+
[
|
|
1195
|
+
"a strict schema",
|
|
1196
|
+
"Additional properties are not allowed ('reasoning_content' was unexpected)",
|
|
1197
|
+
],
|
|
1198
|
+
["Groq", "property 'reasoning_content' is unsupported"],
|
|
1199
|
+
])(
|
|
1200
|
+
"retries once without reasoning_content when %s rejects it",
|
|
1201
|
+
async (_upstream, message) => {
|
|
1202
|
+
const { provider, requests } = stubProviderWithErrors(
|
|
1203
|
+
[rejection(message)],
|
|
1204
|
+
OK_CHUNKS,
|
|
1205
|
+
{ assistantReasoningField: "reasoning_content" },
|
|
1206
|
+
);
|
|
1207
|
+
|
|
1208
|
+
const response = await provider.sendMessage(thinkingHistory);
|
|
1209
|
+
|
|
1210
|
+
expect(requests).toHaveLength(2);
|
|
1211
|
+
const first = requests[0] as {
|
|
1212
|
+
messages: Array<{ reasoning_content?: string; content: string | null }>;
|
|
1213
|
+
};
|
|
1214
|
+
const second = requests[1] as {
|
|
1215
|
+
messages: Array<{ reasoning_content?: string; content: string | null }>;
|
|
1216
|
+
};
|
|
1217
|
+
expect(first.messages[0].reasoning_content).toBe("hidden chain");
|
|
1218
|
+
expect(second.messages[0].reasoning_content).toBeUndefined();
|
|
1219
|
+
expect(second.messages[0].content).toBe("answer");
|
|
1220
|
+
const text = response.content.find((b) => b.type === "text") as
|
|
1221
|
+
| { type: "text"; text: string }
|
|
1222
|
+
| undefined;
|
|
1223
|
+
expect(text?.text).toBe("ok");
|
|
1224
|
+
},
|
|
1225
|
+
);
|
|
1226
|
+
|
|
1227
|
+
test("preserves assistant tool calls when stripping an unsupported reasoning_content", async () => {
|
|
1190
1228
|
const { provider, requests } = stubProviderWithErrors(
|
|
1191
|
-
[
|
|
1192
|
-
rejection(
|
|
1193
|
-
"Additional properties are not allowed ('reasoning_content' was unexpected)",
|
|
1194
|
-
),
|
|
1195
|
-
],
|
|
1229
|
+
[rejection("property 'reasoning_content' is unsupported")],
|
|
1196
1230
|
OK_CHUNKS,
|
|
1197
1231
|
{ assistantReasoningField: "reasoning_content" },
|
|
1198
1232
|
);
|
|
1199
1233
|
|
|
1200
|
-
|
|
1234
|
+
await provider.sendMessage([
|
|
1235
|
+
{
|
|
1236
|
+
role: "assistant",
|
|
1237
|
+
content: [
|
|
1238
|
+
{ type: "thinking", thinking: "hidden chain", signature: "" },
|
|
1239
|
+
{
|
|
1240
|
+
type: "tool_use",
|
|
1241
|
+
id: "call_1",
|
|
1242
|
+
name: "lookup",
|
|
1243
|
+
input: { q: "x" },
|
|
1244
|
+
},
|
|
1245
|
+
],
|
|
1246
|
+
},
|
|
1247
|
+
{
|
|
1248
|
+
role: "user",
|
|
1249
|
+
content: [
|
|
1250
|
+
{ type: "tool_result", tool_use_id: "call_1", content: "found" },
|
|
1251
|
+
],
|
|
1252
|
+
},
|
|
1253
|
+
]);
|
|
1201
1254
|
|
|
1202
1255
|
expect(requests).toHaveLength(2);
|
|
1203
|
-
const first = requests[0] as {
|
|
1204
|
-
messages: Array<{ reasoning_content?: string; content: string | null }>;
|
|
1205
|
-
};
|
|
1206
1256
|
const second = requests[1] as {
|
|
1207
|
-
messages: Array<{
|
|
1257
|
+
messages: Array<{
|
|
1258
|
+
role: string;
|
|
1259
|
+
reasoning_content?: string;
|
|
1260
|
+
tool_calls?: Array<{ id: string; function: { name: string } }>;
|
|
1261
|
+
}>;
|
|
1208
1262
|
};
|
|
1209
|
-
|
|
1210
|
-
expect(
|
|
1211
|
-
expect(
|
|
1212
|
-
|
|
1213
|
-
| { type: "text"; text: string }
|
|
1214
|
-
| undefined;
|
|
1215
|
-
expect(text?.text).toBe("ok");
|
|
1263
|
+
const assistant = second.messages.find((m) => m.role === "assistant");
|
|
1264
|
+
expect(assistant?.reasoning_content).toBeUndefined();
|
|
1265
|
+
expect(assistant?.tool_calls?.[0]?.id).toBe("call_1");
|
|
1266
|
+
expect(assistant?.tool_calls?.[0]?.function.name).toBe("lookup");
|
|
1216
1267
|
});
|
|
1217
1268
|
|
|
1218
1269
|
test("does not strip reasoning_content on a must-be-passed-back error", async () => {
|
|
@@ -1234,6 +1285,38 @@ describe("unknown assistant reasoning field rejection fallback", () => {
|
|
|
1234
1285
|
).toBe("hidden chain");
|
|
1235
1286
|
});
|
|
1236
1287
|
|
|
1288
|
+
test("does not strip reasoning_content on a 429 output-token limit", async () => {
|
|
1289
|
+
const { provider, requests } = stubProviderWithErrors(
|
|
1290
|
+
[
|
|
1291
|
+
rejection(
|
|
1292
|
+
"Rate limit reached for model `qwen/qwen3-32b` in organization `org_x` on tokens per minute (TPM): Limit 1000, Requested 4000.",
|
|
1293
|
+
429,
|
|
1294
|
+
),
|
|
1295
|
+
],
|
|
1296
|
+
OK_CHUNKS,
|
|
1297
|
+
{ assistantReasoningField: "reasoning_content" },
|
|
1298
|
+
);
|
|
1299
|
+
|
|
1300
|
+
await expect(provider.sendMessage(thinkingHistory)).rejects.toThrow();
|
|
1301
|
+
expect(requests).toHaveLength(1);
|
|
1302
|
+
});
|
|
1303
|
+
|
|
1304
|
+
test("does not strip reasoning_content on a 413 input-token limit", async () => {
|
|
1305
|
+
const { provider, requests } = stubProviderWithErrors(
|
|
1306
|
+
[
|
|
1307
|
+
rejection(
|
|
1308
|
+
"Request too large for model `qwen/qwen3-32b` in organization `org_x` on tokens per minute (TPM): Limit 7000, Requested 24936.",
|
|
1309
|
+
413,
|
|
1310
|
+
),
|
|
1311
|
+
],
|
|
1312
|
+
OK_CHUNKS,
|
|
1313
|
+
{ assistantReasoningField: "reasoning_content" },
|
|
1314
|
+
);
|
|
1315
|
+
|
|
1316
|
+
await expect(provider.sendMessage(thinkingHistory)).rejects.toThrow();
|
|
1317
|
+
expect(requests).toHaveLength(1);
|
|
1318
|
+
});
|
|
1319
|
+
|
|
1237
1320
|
test("does not retry unknown-field 500s", async () => {
|
|
1238
1321
|
const { provider, requests } = stubProviderWithErrors(
|
|
1239
1322
|
[
|
|
@@ -565,8 +565,10 @@ function isMissingReasoningContentRejection(
|
|
|
565
565
|
|
|
566
566
|
/**
|
|
567
567
|
* True when the request included an assistant `reasoning` / `reasoning_content`
|
|
568
|
-
* extra and the provider rejected it as an unknown
|
|
569
|
-
* without those extras lets a strict Chat Completions
|
|
568
|
+
* extra and the provider rejected it as an unknown or unsupported message
|
|
569
|
+
* property. One retry without those extras lets a strict Chat Completions
|
|
570
|
+
* schema succeed. Groq phrases this as
|
|
571
|
+
* `property 'reasoning_content' is unsupported`.
|
|
570
572
|
*/
|
|
571
573
|
function isUnknownAssistantReasoningFieldRejection(
|
|
572
574
|
error: unknown,
|
|
@@ -585,7 +587,7 @@ function isUnknownAssistantReasoningFieldRejection(
|
|
|
585
587
|
if (!haystackNamesAssistantReasoningField(haystack)) {
|
|
586
588
|
return false;
|
|
587
589
|
}
|
|
588
|
-
return /unknown|unexpected|unrecognized|additional propert|extra (?:field|property)|not (?:a )?valid|invalid (?:argument|parameter|field|property)/i.test(
|
|
590
|
+
return /unknown|unexpected|unrecognized|unsupported|not supported|additional propert|extra (?:field|property)|not (?:a )?valid|invalid (?:argument|parameter|field|property)/i.test(
|
|
589
591
|
haystack,
|
|
590
592
|
);
|
|
591
593
|
}
|