@vellumai/assistant 0.11.0-dev.202607302020.4a87c7a → 0.11.0-dev.202607302128.ff52e0f
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__/google-calendar-watcher.test.ts +75 -0
- package/src/__tests__/retry-thinking-preadaptive.test.ts +204 -0
- package/src/providers/model-catalog.ts +37 -0
- package/src/providers/retry.ts +20 -1
- package/src/providers/thinking-config.ts +4 -0
- package/src/watcher/__tests__/engine.test.ts +325 -2
- package/src/watcher/__tests__/payload-bounds.test.ts +409 -0
- package/src/watcher/constants.ts +69 -0
- package/src/watcher/engine.ts +135 -25
- package/src/watcher/payload-bounds.ts +441 -0
- package/src/watcher/provider-types.ts +13 -0
- package/src/watcher/providers/github.ts +1 -0
- package/src/watcher/providers/gmail.ts +1 -0
- package/src/watcher/providers/google-calendar.ts +9 -7
- package/src/watcher/providers/linear.ts +1 -0
- package/src/watcher/providers/outlook-calendar.ts +1 -0
- package/src/watcher/providers/outlook.ts +1 -0
package/package.json
CHANGED
|
@@ -44,6 +44,9 @@ mock.module("../util/logger.js", () => ({
|
|
|
44
44
|
// Import module under test after mocks
|
|
45
45
|
const { googleCalendarProvider } =
|
|
46
46
|
await import("../watcher/providers/google-calendar.js");
|
|
47
|
+
const { WATCHER_PAYLOAD_TEXT_MAX_CHARS } =
|
|
48
|
+
await import("../watcher/constants.js");
|
|
49
|
+
const { capPayloadForStorage } = await import("../watcher/payload-bounds.js");
|
|
47
50
|
|
|
48
51
|
// Params that must NOT appear on the sync-token stream. timeMin/timeMax/
|
|
49
52
|
// orderBy/q/updatedMin are forbidden alongside syncToken (per events.list docs)
|
|
@@ -173,3 +176,75 @@ describe("googleCalendarProvider — initial syncToken", () => {
|
|
|
173
176
|
expect(fallback!.orderBy).toBe("startTime");
|
|
174
177
|
});
|
|
175
178
|
});
|
|
179
|
+
|
|
180
|
+
// ── Payload bounds (LUM-2925) ─────────────────────────────────────────
|
|
181
|
+
|
|
182
|
+
describe("googleCalendarProvider: payload bounds", () => {
|
|
183
|
+
function syncResponseWithEvent(description: string) {
|
|
184
|
+
return [
|
|
185
|
+
{
|
|
186
|
+
status: 200,
|
|
187
|
+
body: {
|
|
188
|
+
items: [
|
|
189
|
+
{
|
|
190
|
+
id: "evt-1",
|
|
191
|
+
status: "confirmed",
|
|
192
|
+
summary: "Quarterly review",
|
|
193
|
+
description,
|
|
194
|
+
start: { dateTime: "2026-08-01T10:00:00Z" },
|
|
195
|
+
end: { dateTime: "2026-08-01T11:00:00Z" },
|
|
196
|
+
created: "2026-07-01T00:00:00Z",
|
|
197
|
+
updated: "2026-07-02T00:00:00Z",
|
|
198
|
+
},
|
|
199
|
+
],
|
|
200
|
+
nextSyncToken: "tok_after",
|
|
201
|
+
},
|
|
202
|
+
},
|
|
203
|
+
];
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
test("an oversized description is bounded before it can be stored", async () => {
|
|
207
|
+
// The provider hands the field over as the API returned it. The engine runs
|
|
208
|
+
// `capPayloadForStorage` over the whole payload before Phase 1 serializes it
|
|
209
|
+
// into `watcher_events.payload_json`, which is what bounds the stored row
|
|
210
|
+
// and the `watcher_list` / `watcher_digest` responses built from it. Doing
|
|
211
|
+
// it there covers `location` and every other free-text field, on every
|
|
212
|
+
// provider, without each one naming its own. `engine.test.ts` covers the
|
|
213
|
+
// wiring; this covers what that pass does to a real calendar payload.
|
|
214
|
+
responses = syncResponseWithEvent("D".repeat(50_000));
|
|
215
|
+
|
|
216
|
+
const result = await googleCalendarProvider.fetchNew(
|
|
217
|
+
"google",
|
|
218
|
+
"tok_before",
|
|
219
|
+
{},
|
|
220
|
+
"k",
|
|
221
|
+
);
|
|
222
|
+
|
|
223
|
+
expect(result.items).toHaveLength(1);
|
|
224
|
+
const stored = JSON.parse(
|
|
225
|
+
JSON.stringify(capPayloadForStorage(result.items[0]!.payload)),
|
|
226
|
+
);
|
|
227
|
+
expect(stored.description.length).toBe(WATCHER_PAYLOAD_TEXT_MAX_CHARS);
|
|
228
|
+
// Bounding truncates, it does not drop the field.
|
|
229
|
+
expect(stored.description.startsWith("D".repeat(1_000))).toBe(true);
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
test("a normal description passes through unchanged and unfenced", async () => {
|
|
233
|
+
// The engine wraps the whole rendered event block in one
|
|
234
|
+
// <external_content> envelope, so a per-field wrapper here would only nest
|
|
235
|
+
// an escaped fence inside that one.
|
|
236
|
+
responses = syncResponseWithEvent("Bring the Q3 deck.");
|
|
237
|
+
|
|
238
|
+
const result = await googleCalendarProvider.fetchNew(
|
|
239
|
+
"google",
|
|
240
|
+
"tok_before",
|
|
241
|
+
{},
|
|
242
|
+
"k",
|
|
243
|
+
);
|
|
244
|
+
|
|
245
|
+
expect(result.items[0]!.payload.description).toBe("Bring the Q3 deck.");
|
|
246
|
+
expect(JSON.stringify(result.items[0]!.payload)).not.toContain(
|
|
247
|
+
"external_content",
|
|
248
|
+
);
|
|
249
|
+
});
|
|
250
|
+
});
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Verifies that `RetryProvider.normalizeSendMessageOptions` drops an adaptive
|
|
3
|
+
* thinking config for pre-adaptive Claude models (Haiku 4.5, Opus 4.5,
|
|
4
|
+
* Sonnet 4.5), preventing an Anthropic 400: these models reject
|
|
5
|
+
* `thinking: { type: "adaptive" }` and only support the legacy
|
|
6
|
+
* `{ type: "enabled", budget_tokens }` form, which Vellum never sends.
|
|
7
|
+
*
|
|
8
|
+
* The legacy budget_tokens form supplied by pass-through callers is preserved,
|
|
9
|
+
* as is adaptive thinking on models that support it.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { beforeEach, describe, expect, test } from "bun:test";
|
|
13
|
+
|
|
14
|
+
import { RetryProvider } from "../providers/retry.js";
|
|
15
|
+
import type {
|
|
16
|
+
Message,
|
|
17
|
+
Provider,
|
|
18
|
+
ProviderResponse,
|
|
19
|
+
SendMessageOptions,
|
|
20
|
+
} from "../providers/types.js";
|
|
21
|
+
import { setConfig } from "./helpers/set-config.js";
|
|
22
|
+
|
|
23
|
+
function setLlmConfig(raw: unknown): void {
|
|
24
|
+
setConfig("llm", raw);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
beforeEach(() => {
|
|
28
|
+
setConfig("llm", {});
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
function makePipeline(providerName: string): {
|
|
32
|
+
provider: Provider;
|
|
33
|
+
lastConfig: () => Record<string, unknown> | undefined;
|
|
34
|
+
} {
|
|
35
|
+
let captured: Record<string, unknown> | undefined;
|
|
36
|
+
const inner: Provider = {
|
|
37
|
+
name: providerName,
|
|
38
|
+
async sendMessage(
|
|
39
|
+
_messages: Message[],
|
|
40
|
+
options?: SendMessageOptions,
|
|
41
|
+
): Promise<ProviderResponse> {
|
|
42
|
+
captured = options?.config as Record<string, unknown> | undefined;
|
|
43
|
+
return {
|
|
44
|
+
content: [],
|
|
45
|
+
model: "test",
|
|
46
|
+
usage: { inputTokens: 0, outputTokens: 0 },
|
|
47
|
+
stopReason: "stop",
|
|
48
|
+
};
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
return {
|
|
52
|
+
provider: new RetryProvider(inner),
|
|
53
|
+
lastConfig: () => captured,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const userMessage: Message = {
|
|
58
|
+
role: "user",
|
|
59
|
+
content: [{ type: "text", text: "hi" }],
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
describe("retry normalization: pre-adaptive thinking models", () => {
|
|
63
|
+
test("drops resolved thinking: enabled for Haiku 4.5", async () => {
|
|
64
|
+
// GIVEN a call-site config that enables thinking for Haiku 4.5, which
|
|
65
|
+
// rejects the adaptive wire shape the config normalizes to
|
|
66
|
+
setLlmConfig({
|
|
67
|
+
callSites: {
|
|
68
|
+
memoryExtraction: {
|
|
69
|
+
provider: "anthropic",
|
|
70
|
+
model: "claude-haiku-4-5-20251001",
|
|
71
|
+
thinking: { enabled: true },
|
|
72
|
+
effort: "high",
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
});
|
|
76
|
+
const { provider, lastConfig } = makePipeline("anthropic");
|
|
77
|
+
|
|
78
|
+
// WHEN a request resolves through the call-site config
|
|
79
|
+
await provider.sendMessage([userMessage], {
|
|
80
|
+
config: { callSite: "memoryExtraction" },
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
// THEN the adaptive thinking config is dropped so the request goes out
|
|
84
|
+
// without thinking instead of 400-ing
|
|
85
|
+
expect(lastConfig()?.thinking).toBeUndefined();
|
|
86
|
+
// AND effort is still forwarded
|
|
87
|
+
expect(lastConfig()?.effort).toBe("high");
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
test("drops explicit wire-shape adaptive thinking from pass-through callers for Haiku 4.5", async () => {
|
|
91
|
+
// GIVEN a pass-through caller supplying the wire-shape adaptive config
|
|
92
|
+
const { provider, lastConfig } = makePipeline("anthropic");
|
|
93
|
+
|
|
94
|
+
// WHEN sending against Haiku 4.5
|
|
95
|
+
await provider.sendMessage([userMessage], {
|
|
96
|
+
config: {
|
|
97
|
+
model: "claude-haiku-4-5-20251001",
|
|
98
|
+
thinking: { type: "adaptive" },
|
|
99
|
+
},
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
// THEN the adaptive thinking config is dropped
|
|
103
|
+
expect(lastConfig()?.thinking).toBeUndefined();
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
test("preserves legacy budget_tokens thinking for Haiku 4.5", async () => {
|
|
107
|
+
// GIVEN a pass-through caller supplying the legacy budget form, which
|
|
108
|
+
// Haiku 4.5 does support
|
|
109
|
+
const { provider, lastConfig } = makePipeline("anthropic");
|
|
110
|
+
|
|
111
|
+
// WHEN sending against Haiku 4.5
|
|
112
|
+
await provider.sendMessage([userMessage], {
|
|
113
|
+
config: {
|
|
114
|
+
model: "claude-haiku-4-5-20251001",
|
|
115
|
+
thinking: { type: "enabled", budget_tokens: 4096 },
|
|
116
|
+
},
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
// THEN the legacy config is forwarded untouched
|
|
120
|
+
expect(lastConfig()?.thinking).toEqual({
|
|
121
|
+
type: "enabled",
|
|
122
|
+
budget_tokens: 4096,
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
test("drops adaptive thinking for OpenRouter-proxied Haiku 4.5", async () => {
|
|
127
|
+
// GIVEN a call-site config enabling thinking on the OpenRouter-proxied
|
|
128
|
+
// Haiku id
|
|
129
|
+
setLlmConfig({
|
|
130
|
+
callSites: {
|
|
131
|
+
memoryExtraction: {
|
|
132
|
+
provider: "openrouter",
|
|
133
|
+
model: "anthropic/claude-haiku-4.5",
|
|
134
|
+
thinking: { enabled: true },
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
});
|
|
138
|
+
const { provider, lastConfig } = makePipeline("openrouter");
|
|
139
|
+
|
|
140
|
+
// WHEN a request resolves through the call-site config
|
|
141
|
+
await provider.sendMessage([userMessage], {
|
|
142
|
+
config: { callSite: "memoryExtraction" },
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
// THEN the adaptive thinking config is dropped
|
|
146
|
+
expect(lastConfig()?.thinking).toBeUndefined();
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
test("drops adaptive thinking for Opus 4.5 and Sonnet 4.5", async () => {
|
|
150
|
+
for (const model of [
|
|
151
|
+
"claude-opus-4-5-20251101",
|
|
152
|
+
"claude-sonnet-4-5-20250929",
|
|
153
|
+
]) {
|
|
154
|
+
const { provider, lastConfig } = makePipeline("anthropic");
|
|
155
|
+
|
|
156
|
+
await provider.sendMessage([userMessage], {
|
|
157
|
+
config: { model, thinking: { type: "adaptive" } },
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
expect(lastConfig()?.thinking).toBeUndefined();
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
test("drops adaptive thinking for undated model aliases", async () => {
|
|
165
|
+
// Anthropic serves undated aliases for dated catalog IDs, and profiles
|
|
166
|
+
// and the CLI accept either form (inference.help.ts advertises
|
|
167
|
+
// `--model claude-haiku-4-5`)
|
|
168
|
+
for (const model of [
|
|
169
|
+
"claude-haiku-4-5",
|
|
170
|
+
"claude-opus-4-5",
|
|
171
|
+
"claude-sonnet-4-5",
|
|
172
|
+
]) {
|
|
173
|
+
const { provider, lastConfig } = makePipeline("anthropic");
|
|
174
|
+
|
|
175
|
+
await provider.sendMessage([userMessage], {
|
|
176
|
+
config: { model, thinking: { type: "adaptive" } },
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
expect(lastConfig()?.thinking).toBeUndefined();
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
test("preserves adaptive thinking for models that support it", async () => {
|
|
184
|
+
// GIVEN a call-site config that enables thinking for Opus 4.8
|
|
185
|
+
setLlmConfig({
|
|
186
|
+
callSites: {
|
|
187
|
+
memoryExtraction: {
|
|
188
|
+
provider: "anthropic",
|
|
189
|
+
model: "claude-opus-4-8",
|
|
190
|
+
thinking: { enabled: true },
|
|
191
|
+
},
|
|
192
|
+
},
|
|
193
|
+
});
|
|
194
|
+
const { provider, lastConfig } = makePipeline("anthropic");
|
|
195
|
+
|
|
196
|
+
// WHEN a request resolves through the call-site config
|
|
197
|
+
await provider.sendMessage([userMessage], {
|
|
198
|
+
config: { callSite: "memoryExtraction" },
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
// THEN adaptive thinking is preserved
|
|
202
|
+
expect(lastConfig()?.thinking).toEqual({ type: "adaptive" });
|
|
203
|
+
});
|
|
204
|
+
});
|
|
@@ -50,6 +50,15 @@ export interface CatalogModel {
|
|
|
50
50
|
* before dispatching. Implies `supportsThinking`.
|
|
51
51
|
*/
|
|
52
52
|
adaptiveThinkingOnly?: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* When true, the model predates adaptive thinking and rejects
|
|
55
|
+
* `thinking: { type: "adaptive" }` (Anthropic 400s such calls). It only
|
|
56
|
+
* supports the legacy `{ type: "enabled", budget_tokens }` form, which
|
|
57
|
+
* Vellum never sends. The daemon drops an enabled thinking config for these
|
|
58
|
+
* models before dispatching to the Anthropic wire. Mutually exclusive with
|
|
59
|
+
* `adaptiveThinkingOnly`.
|
|
60
|
+
*/
|
|
61
|
+
adaptiveThinkingUnsupported?: boolean;
|
|
53
62
|
supportsCaching?: boolean;
|
|
54
63
|
supportsVision?: boolean;
|
|
55
64
|
/**
|
|
@@ -296,6 +305,7 @@ const RAW_PROVIDER_CATALOG: ProviderCatalogEntry[] = [
|
|
|
296
305
|
contextWindowTokens: 200000,
|
|
297
306
|
maxOutputTokens: 64000,
|
|
298
307
|
supportsThinking: true,
|
|
308
|
+
adaptiveThinkingUnsupported: true,
|
|
299
309
|
supportsCaching: true,
|
|
300
310
|
supportsVision: true,
|
|
301
311
|
supportsToolUse: true,
|
|
@@ -312,6 +322,7 @@ const RAW_PROVIDER_CATALOG: ProviderCatalogEntry[] = [
|
|
|
312
322
|
contextWindowTokens: 200000,
|
|
313
323
|
maxOutputTokens: 64000,
|
|
314
324
|
supportsThinking: true,
|
|
325
|
+
adaptiveThinkingUnsupported: true,
|
|
315
326
|
supportsCaching: true,
|
|
316
327
|
supportsVision: true,
|
|
317
328
|
supportsToolUse: true,
|
|
@@ -328,6 +339,7 @@ const RAW_PROVIDER_CATALOG: ProviderCatalogEntry[] = [
|
|
|
328
339
|
contextWindowTokens: 200000,
|
|
329
340
|
maxOutputTokens: 64000,
|
|
330
341
|
supportsThinking: true,
|
|
342
|
+
adaptiveThinkingUnsupported: true,
|
|
331
343
|
supportsCaching: true,
|
|
332
344
|
supportsVision: true,
|
|
333
345
|
supportsToolUse: true,
|
|
@@ -1140,6 +1152,7 @@ const RAW_PROVIDER_CATALOG: ProviderCatalogEntry[] = [
|
|
|
1140
1152
|
contextWindowTokens: 200000,
|
|
1141
1153
|
maxOutputTokens: 64000,
|
|
1142
1154
|
supportsThinking: true,
|
|
1155
|
+
adaptiveThinkingUnsupported: true,
|
|
1143
1156
|
supportsCaching: true,
|
|
1144
1157
|
supportsVision: true,
|
|
1145
1158
|
supportsToolUse: true,
|
|
@@ -1156,6 +1169,7 @@ const RAW_PROVIDER_CATALOG: ProviderCatalogEntry[] = [
|
|
|
1156
1169
|
contextWindowTokens: 200000,
|
|
1157
1170
|
maxOutputTokens: 64000,
|
|
1158
1171
|
supportsThinking: true,
|
|
1172
|
+
adaptiveThinkingUnsupported: true,
|
|
1159
1173
|
supportsCaching: true,
|
|
1160
1174
|
supportsVision: true,
|
|
1161
1175
|
supportsToolUse: true,
|
|
@@ -1172,6 +1186,7 @@ const RAW_PROVIDER_CATALOG: ProviderCatalogEntry[] = [
|
|
|
1172
1186
|
contextWindowTokens: 200000,
|
|
1173
1187
|
maxOutputTokens: 64000,
|
|
1174
1188
|
supportsThinking: true,
|
|
1189
|
+
adaptiveThinkingUnsupported: true,
|
|
1175
1190
|
supportsCaching: true,
|
|
1176
1191
|
supportsVision: true,
|
|
1177
1192
|
supportsToolUse: true,
|
|
@@ -1873,6 +1888,7 @@ const RAW_PROVIDER_CATALOG: ProviderCatalogEntry[] = [
|
|
|
1873
1888
|
contextWindowTokens: 200000,
|
|
1874
1889
|
maxOutputTokens: 64000,
|
|
1875
1890
|
supportsThinking: true,
|
|
1891
|
+
adaptiveThinkingUnsupported: true,
|
|
1876
1892
|
supportsCaching: true,
|
|
1877
1893
|
supportsVision: true,
|
|
1878
1894
|
supportsToolUse: true,
|
|
@@ -2236,6 +2252,27 @@ export function isAdaptiveThinkingOnlyModel(modelId: string): boolean {
|
|
|
2236
2252
|
);
|
|
2237
2253
|
}
|
|
2238
2254
|
|
|
2255
|
+
/**
|
|
2256
|
+
* Whether the given model predates adaptive thinking and rejects
|
|
2257
|
+
* `thinking: { type: "adaptive" }`, driven by the `adaptiveThinkingUnsupported`
|
|
2258
|
+
* capability in the catalog. Matches the model ID across every provider (same
|
|
2259
|
+
* pattern as {@link isAdaptiveThinkingOnlyModel}), and also matches the
|
|
2260
|
+
* undated aliases Anthropic serves for dated catalog IDs (`claude-haiku-4-5`
|
|
2261
|
+
* resolves the same model as `claude-haiku-4-5-20251001`), since profiles and
|
|
2262
|
+
* the CLI accept either form.
|
|
2263
|
+
*/
|
|
2264
|
+
export function isAdaptiveThinkingUnsupportedModel(modelId: string): boolean {
|
|
2265
|
+
const stripDateSuffix = (id: string): string => id.replace(/-\d{8}$/, "");
|
|
2266
|
+
const normalized = stripDateSuffix(modelId);
|
|
2267
|
+
return PROVIDER_CATALOG.some((p) =>
|
|
2268
|
+
p.models.some(
|
|
2269
|
+
(m) =>
|
|
2270
|
+
m.adaptiveThinkingUnsupported === true &&
|
|
2271
|
+
(m.id === modelId || stripDateSuffix(m.id) === normalized),
|
|
2272
|
+
),
|
|
2273
|
+
);
|
|
2274
|
+
}
|
|
2275
|
+
|
|
2239
2276
|
/**
|
|
2240
2277
|
* Whether a model's serving surface accepts OpenAI chat-completions
|
|
2241
2278
|
* `input_audio` content parts, driven by the `supportsAudioInput` capability
|
package/src/providers/retry.ts
CHANGED
|
@@ -18,8 +18,12 @@ import {
|
|
|
18
18
|
isAnthropicModel,
|
|
19
19
|
} from "./anthropic-gateway-shared.js";
|
|
20
20
|
import { resolveLogitBiasPreset } from "./inference/logit-bias.js";
|
|
21
|
-
import { isAdaptiveThinkingOnlyModel } from "./model-catalog.js";
|
|
22
21
|
import {
|
|
22
|
+
isAdaptiveThinkingOnlyModel,
|
|
23
|
+
isAdaptiveThinkingUnsupportedModel,
|
|
24
|
+
} from "./model-catalog.js";
|
|
25
|
+
import {
|
|
26
|
+
isThinkingConfigAdaptive,
|
|
23
27
|
isThinkingConfigDisabled,
|
|
24
28
|
normalizeThinkingConfigForWire,
|
|
25
29
|
} from "./thinking-config.js";
|
|
@@ -551,6 +555,21 @@ function normalizeSendMessageOptions(
|
|
|
551
555
|
delete nextConfig.thinking;
|
|
552
556
|
}
|
|
553
557
|
|
|
558
|
+
// Pre-adaptive Claude models (Haiku 4.5, Opus 4.5, Sonnet 4.5) reject
|
|
559
|
+
// `thinking: { type: "adaptive" }` (Anthropic 400s the request), and Vellum
|
|
560
|
+
// never sends the legacy budget_tokens form. Drop an adaptive thinking
|
|
561
|
+
// config for these models so the request goes out without thinking instead
|
|
562
|
+
// of failing. A pass-through `{ type: "enabled", budget_tokens }` config is
|
|
563
|
+
// left intact: these models do support that shape.
|
|
564
|
+
if (
|
|
565
|
+
typeof nextConfig.model === "string" &&
|
|
566
|
+
isAdaptiveThinkingUnsupportedModel(nextConfig.model) &&
|
|
567
|
+
isThinkingConfigAdaptive(nextConfig.thinking) &&
|
|
568
|
+
targetsAnthropicWire(providerName, nextConfig.model)
|
|
569
|
+
) {
|
|
570
|
+
delete nextConfig.thinking;
|
|
571
|
+
}
|
|
572
|
+
|
|
554
573
|
// thinking is Anthropic-specific on the wire; OpenRouter reads it as a
|
|
555
574
|
// signal for its unified reasoning parameter; Gemini reads `level` from it.
|
|
556
575
|
// Strip it for other providers.
|
|
@@ -55,6 +55,10 @@ export function isThinkingConfigDisabled(thinking: unknown): boolean {
|
|
|
55
55
|
return normalizeThinkingConfigForWire(thinking)?.type === "disabled";
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
+
export function isThinkingConfigAdaptive(thinking: unknown): boolean {
|
|
59
|
+
return normalizeThinkingConfigForWire(thinking)?.type === "adaptive";
|
|
60
|
+
}
|
|
61
|
+
|
|
58
62
|
export function isThinkingConfigEnabled(thinking: unknown): boolean {
|
|
59
63
|
const normalized = normalizeThinkingConfigForWire(thinking);
|
|
60
64
|
return normalized !== undefined && normalized.type !== "disabled";
|