@namzu/anthropic 2.0.0 → 3.0.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,189 @@
1
1
  # Changelog
2
2
 
3
+ ## 3.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - f8355de: tool schemas are rendered in the dialect each wire actually parses
8
+
9
+ A tool with a tuple-shaped field took down every request that offered it. The
10
+ kernel renders one canonical JSON Schema in draft-07, where a tuple is
11
+ `items: [a, b]`; one of the wires namzu speaks validates tool input as JSON
12
+ Schema 2020-12, where that spelling is invalid and a tuple must be
13
+ `prefixItems`. Every driver forwarded the rendering verbatim, so the built-in
14
+ `read` tool — whose `readRange` is a Zod tuple — produced a 400 that rejected
15
+ the **whole** request, taking every other tool in the call down with it. The
16
+ turn died before generating a token.
17
+
18
+ The failure had nothing to do with strict tool use, which is why the guard
19
+ added for the previous schema outage never saw it: it fires with strict
20
+ validation unset, and with strict on the dialect error arrives _first_.
21
+
22
+ Which dialect a wire parses is a property of the wire, so the conversion now
23
+ happens at each driver's boundary rather than in the renderer:
24
+
25
+ ```ts
26
+ import { toSchemaDialect, findDraft07Only } from "@namzu/sdk";
27
+
28
+ toSchemaDialect(schema, "2020-12"); // items: [a, b] -> prefixItems: [a, b]
29
+ findDraft07Only(schema); // paths that no 2020-12 parser will accept
30
+ ```
31
+
32
+ `renderToolSchema` is exported now too, so a caller assembling its own tool
33
+ payload gets the same memoized, `$schema`-stripped, deep-frozen rendering the
34
+ kernel puts on the wire — byte-identical across iterations, which matters
35
+ because the tools block sits at position 0 of the prompt-cache prefix.
36
+
37
+ `ToolCatalog` used to convert schemas through its own inline call with the same
38
+ options. Same output, none of the guarantees: no `$schema` stripping, no
39
+ memoization, no freeze. It goes through `renderToolSchema` now.
40
+
41
+ **Breaking, for the three drivers.** Their `@namzu/sdk` peer range was
42
+ `>=1.3.0` and is now `>=6.0.0`. That range was already wrong — the drivers call
43
+ kernel functions added well after 1.3.0 — and it would now let a package
44
+ manager install a combination that throws on every request carrying a tool.
45
+ Upgrade the kernel alongside the driver.
46
+
47
+ The conversion follows the model on multi-vendor wires. Bedrock's Converse API
48
+ carries several vendors through one request shape, and the 2020-12 requirement
49
+ was measured on one of them, so schemas bound for the others are left in the
50
+ dialect they were rendered in. Guessing there would trade a known break for an
51
+ unmeasured one.
52
+
53
+ ### Patch Changes
54
+
55
+ - f8355de: reasoning effort is dropped only on the models that actually refuse it
56
+
57
+ With thinking switched off, the driver discarded `xhigh` and `max` on every
58
+ model that can switch thinking off. The reasoning was that the pairing is
59
+ incoherent anyway — asking a model not to think and then to think as hard as
60
+ possible.
61
+
62
+ Measured against the live API, the rule was too wide. One model family rejects
63
+ that combination with _"effort is not supported when thinking is disabled"_;
64
+ its siblings accept it and honour the effort. So the blanket rule was silently
65
+ discarding a setting the caller asked for and the wire would have applied, on
66
+ models where nothing was wrong.
67
+
68
+ Looking incoherent is not the same as being rejected, and only the wire decides
69
+ which. The capability table now carries the levels accepted with thinking off
70
+ as a separate set from the levels accepted generally, because on most models
71
+ those two sets are identical and on one family they are not.
72
+
73
+ ## 2.0.1
74
+
75
+ ### Patch Changes
76
+
77
+ - f25ebce: a model id's date suffix is no longer read as its minor version
78
+
79
+ Three copies of one regular expression matched Claude model ids — the capability
80
+ table plus two drivers — and all three had the same defect: the minor-version
81
+ group was `(\d+)`, which swallowed the 8-digit date suffix.
82
+
83
+ Measured against the shipped pattern:
84
+
85
+ ```
86
+ claude-sonnet-4-20250514 -> major=4 minor=20250514
87
+ claude-opus-4-1-20250805 -> major=4 minor=1
88
+ ```
89
+
90
+ So a dated id naming no minor version compared as enormously _newer_ than one
91
+ that does, and every capability gate keyed on `minor >= n` inverted for exactly
92
+ those ids. `claude-sonnet-4-20250514` was classified as a 4.7+ model: the driver
93
+ sent it `thinking: {type: 'adaptive'}`, silently discarding a caller's
94
+ `budgetTokens`, and cleared the 4.5 gate that enables strict tool inputs.
95
+
96
+ `parseClaudeModelVersion` and `claudeVersionAtLeast` are now exported from
97
+ `@namzu/sdk` and used by both drivers and the capability table. A real minor
98
+ version is one to three digits; a date is eight, and the group is bounded
99
+ accordingly. An id the parser does not recognise makes `claudeVersionAtLeast`
100
+ return `false` — a capability gate must not open for a name it does not
101
+ understand.
102
+
103
+ The comment above the old parser warned that "a second, subtly different model
104
+ matcher is how two capability decisions drift apart on the same model name."
105
+ There were three.
106
+
107
+ - f25ebce: an effort level a model does not have is no longer sent
108
+
109
+ `ThinkingCapability.effort` was a boolean — "does this model take an effort
110
+ hint?" — and that was never the question. The ceiling moved twice: `xhigh`
111
+ arrived with 4.7, and `max` does not exist below 4.6. The accepted levels are a
112
+ **set**, and a flag could not say that `xhigh` is rejected on a 4.6 or that
113
+ `max` is rejected on a 4.5.
114
+
115
+ While it was a flag, both of those went to the wire, and the vendor rejects an
116
+ unknown level rather than clamping it — so a caller who set `effort: 'xhigh'`
117
+ and pointed at a 4.6 got a failed request, not a slightly different answer.
118
+
119
+ The driver now checks the level against the model:
120
+
121
+ | model | accepted levels |
122
+ | ----------------------------------------- | ----------------------------------- |
123
+ | 4.7 and later, and the always-on families | `low` `medium` `high` `xhigh` `max` |
124
+ | 4.6 | `low` `medium` `high` `max` |
125
+ | Opus 4.5 | `low` `medium` `high` |
126
+ | everything else | none |
127
+
128
+ A level the model does not have is dropped rather than refused: `effort` shapes
129
+ an answer the model will still produce, so a request without it is the same
130
+ request at the model's own default — whereas refusing would fail a call that
131
+ has a correct answer. The existing rule about disabled thinking at `xhigh`/`max`
132
+ is unchanged.
133
+
134
+ `patch`, not `minor` or `major`: `ThinkingCapability` is internal to this
135
+ package. The entry point exports `registerAnthropic`, `AnthropicProvider`,
136
+ `ANTHROPIC_CAPABILITIES` and two config types, and the changed field is
137
+ reachable from none of them — so no consumer's code compiles differently. What
138
+ a consumer sees is only that a request that used to fail now succeeds.
139
+
140
+ The capability table's tests now cover every currently-served model with its
141
+ level set, plus the dated-id shape that previously parsed a release date as a
142
+ minor version.
143
+
144
+ - f25ebce: the edit tool's schema could not be sent under strict validation
145
+
146
+ Strict tool input is not "JSON Schema, enforced" — it is a **subset** of JSON
147
+ Schema, and a keyword outside that subset is not degraded. The vendor rejects
148
+ the whole request, so one unexpressible field in one tool takes every other
149
+ tool down with it and the turn dies before producing a token.
150
+
151
+ The `edit` tool declared its integer-or-`"end"` field with `oneOf`, which is
152
+ outside the subset while the equivalent `anyOf` is inside it. Measured against
153
+ the live API:
154
+
155
+ | body | result |
156
+ | ------------------------- | ------------------------------------------------ |
157
+ | `strict: true` + `oneOf` | **400** — `Schema type 'oneOf' is not supported` |
158
+ | `strict: false` + `oneOf` | accepted |
159
+ | `strict: true` + `anyOf` | accepted |
160
+
161
+ The middle row is why nothing caught it. Neither half is wrong on its own — the
162
+ schema is valid JSON Schema, and marking the tool strict is correct policy — so
163
+ no test of either one failed. Only the pairing did, and the pairing had no
164
+ owner. Every agent using the built-in `edit` tool on a model at or above the
165
+ strict gate lost its first tool-carrying turn to a 400.
166
+
167
+ `oneOf` is now `anyOf` (equivalent here — the branches are disjoint), and
168
+ `minimum` is gone from the model-facing schema for the same reason: numeric
169
+ bounds are outside the subset too. The bound is not lost, the execution schema
170
+ still enforces it.
171
+
172
+ **The general fix is the second half.** `assertStrictSchema` and
173
+ `findStrictSchemaViolations` are exported from `@namzu/sdk`, and the driver now
174
+ checks every schema it is about to mark strict — refusing with the exact path
175
+ and the remedy rather than letting the request go and getting back an error
176
+ that names the keyword but not where it lives:
177
+
178
+ ```
179
+ Tool "edit" is marked for strict input validation, but its model-facing schema
180
+ uses 1 construct(s) the strict subset does not accept…
181
+ edit.properties.insertLine.oneOf — use `anyOf` — for disjoint branches the two are equivalent
182
+ ```
183
+
184
+ A test sweeps every built-in tool that asks for strict validation, so the next
185
+ one is caught in the suite rather than in production.
186
+
3
187
  ## 2.0.0
4
188
 
5
189
  ### Major Changes
@@ -11,26 +11,51 @@ import { resolveEffort, resolveThinkingBody, resolveThinkingCapability, } from '
11
11
  * case per row, because that table IS the specification — a summary of it in
12
12
  * prose would be the thing that drifts.
13
13
  */
14
- /** [model, adaptive, manual, canDisable, effort] */
14
+ const ALL = ['low', 'medium', 'high', 'xhigh', 'max'];
15
+ /** 4.6 has `max` but not `xhigh` — `xhigh` arrived with 4.7. */
16
+ const NO_XHIGH = ['low', 'medium', 'high', 'max'];
17
+ /** 4.5 has neither. */
18
+ const BASE = ['low', 'medium', 'high'];
19
+ const NONE = [];
20
+ /**
21
+ * [model, adaptive, manual, canDisable, effort levels]
22
+ *
23
+ * Every currently-served model, plus the legacy ones a gateway may still be
24
+ * pointed at. `effort` is the accepted LEVELS, not a flag: the ceiling moved
25
+ * twice, so a boolean could not say that `xhigh` is rejected on 4.6 and `max`
26
+ * is rejected on 4.5 — which is exactly what it failed to say.
27
+ */
28
+ const CAPPED = BASE; // opus 5+ with thinking off
15
29
  const TABLE = [
16
- ['claude-fable-5', true, false, false, true],
17
- ['claude-mythos-5', true, false, false, true],
18
- ['claude-mythos-preview', true, true, false, true],
19
- ['claude-opus-5', true, false, true, true],
20
- ['claude-opus-4-8', true, false, true, true],
21
- ['claude-opus-4-7', true, false, true, true],
22
- ['claude-sonnet-5', true, false, true, true],
23
- ['claude-opus-4-6', true, true, true, true],
24
- ['claude-sonnet-4-6', true, true, true, true],
25
- ['claude-opus-4-5', false, true, true, true],
26
- ['claude-haiku-4-5', false, true, true, false],
27
- ['claude-sonnet-4-5', false, true, true, false],
28
- ['claude-opus-4-1', false, true, true, false],
30
+ // Always-on families: thinking cannot be switched off at any version.
31
+ ['claude-fable-5', true, false, false, ALL, ALL],
32
+ ['claude-mythos-5', true, false, false, ALL, ALL],
33
+ ['claude-mythos-preview', true, true, false, ALL, ALL],
34
+ // 4.7 and later: adaptive only, and it can still be disabled.
35
+ ['claude-opus-5', true, false, true, ALL, CAPPED],
36
+ ['claude-sonnet-5', true, false, true, ALL, ALL],
37
+ ['claude-opus-4-8', true, false, true, ALL, ALL],
38
+ ['claude-opus-4-7', true, false, true, ALL, ALL],
39
+ // 4.6: both modes, manual deprecated but working — and no `xhigh`.
40
+ ['claude-opus-4-6', true, true, true, NO_XHIGH, NO_XHIGH],
41
+ ['claude-sonnet-4-6', true, true, true, NO_XHIGH, NO_XHIGH],
42
+ // 4.5 and earlier: manual only. Opus 4.5 is the one that takes effort,
43
+ // and only the first three levels.
44
+ ['claude-opus-4-5', false, true, true, BASE, BASE],
45
+ ['claude-haiku-4-5', false, true, true, NONE, NONE],
46
+ ['claude-sonnet-4-5', false, true, true, NONE, NONE],
47
+ ['claude-opus-4-1', false, true, true, NONE, NONE],
29
48
  ];
30
49
  describe('what each model accepts', () => {
31
- for (const [model, adaptive, manual, canDisable, effort] of TABLE) {
50
+ for (const [model, adaptive, manual, canDisable, effort, effortWhenDisabled] of TABLE) {
32
51
  it(`resolves ${model}`, () => {
33
- expect(resolveThinkingCapability(model)).toEqual({ adaptive, manual, canDisable, effort });
52
+ expect(resolveThinkingCapability(model)).toEqual({
53
+ adaptive,
54
+ manual,
55
+ canDisable,
56
+ effort,
57
+ effortWhenDisabled,
58
+ });
34
59
  });
35
60
  }
36
61
  it('tolerates a vendor prefix and a date suffix', () => {
@@ -43,6 +68,20 @@ describe('what each model accepts', () => {
43
68
  manual: true,
44
69
  });
45
70
  });
71
+ it('does not read a date suffix as the minor version', () => {
72
+ // The row this table did not have. Every dated id it listed carried a
73
+ // REAL minor (`4-5-20250929`), so the `<family>-<major>-<DATE>` shape —
74
+ // a dated id naming no minor — was never exercised, and the matcher
75
+ // parsed its date as minor 20250514. That compared as enormously newer
76
+ // than 4.1, so these two were classified adaptive-only and had their
77
+ // caller's thinking budget silently discarded.
78
+ for (const model of ['claude-sonnet-4-20250514', 'claude-opus-4-20250514']) {
79
+ expect(resolveThinkingCapability(model), model).toMatchObject({
80
+ adaptive: false,
81
+ manual: true,
82
+ });
83
+ }
84
+ });
46
85
  it('treats an unrecognised model as manual-only', () => {
47
86
  // The pre-existing behaviour, and the safe answer for a name this
48
87
  // table has not seen: an older model behind a gateway keeps working,
@@ -52,7 +91,8 @@ describe('what each model accepts', () => {
52
91
  adaptive: false,
53
92
  manual: true,
54
93
  canDisable: true,
55
- effort: false,
94
+ effort: [],
95
+ effortWhenDisabled: [],
56
96
  });
57
97
  });
58
98
  });
@@ -116,12 +156,46 @@ describe('when effort rides along', () => {
116
156
  const opus45 = resolveThinkingCapability('claude-opus-4-5');
117
157
  expect(resolveEffort('high', { type: 'enabled', budget_tokens: 8000 }, opus45)).toBe('high');
118
158
  });
119
- it('refuses the combination the vendor rejects', () => {
120
- // Thinking off at effort xhigh/max is a 400 on Opus 5 and later, and
121
- // is incoherent anyway: do not think, and think as hard as possible.
122
- expect(resolveEffort('xhigh', { type: 'disabled' }, adaptiveOnly)).toBeUndefined();
123
- expect(resolveEffort('max', { type: 'disabled' }, adaptiveOnly)).toBeUndefined();
124
- expect(resolveEffort('high', { type: 'disabled' }, adaptiveOnly)).toBe('high');
159
+ it('caps effort with thinking off only where the wire caps it', () => {
160
+ // This rule used to be blanket: thinking off at `xhigh`/`max` was
161
+ // refused on every model that can disable thinking, reasoning that the
162
+ // pairing is incoherent anyway. Measured against the live API, that was
163
+ // too wide — only the Opus 5 family rejects it:
164
+ //
165
+ // claude-opus-5 + disabled + max -> 400 "not supported when thinking is disabled"
166
+ // claude-sonnet-5 + disabled + max -> accepted
167
+ // claude-opus-4-8 + disabled + max -> accepted
168
+ //
169
+ // So the blanket rule was dropping an effort the caller asked for and
170
+ // the wire would have honoured. Looking incoherent is not the same as
171
+ // being rejected, and only the wire decides which.
172
+ const opus5 = resolveThinkingCapability('claude-opus-5');
173
+ expect(resolveEffort('max', { type: 'disabled' }, opus5)).toBeUndefined();
174
+ expect(resolveEffort('xhigh', { type: 'disabled' }, opus5)).toBeUndefined();
175
+ expect(resolveEffort('high', { type: 'disabled' }, opus5)).toBe('high');
176
+ // …and uncapped with thinking on, on the same model.
177
+ expect(resolveEffort('max', { type: 'adaptive' }, opus5)).toBe('max');
178
+ // `adaptiveOnly` here is Sonnet 5, which the wire does not cap.
179
+ expect(resolveEffort('max', { type: 'disabled' }, adaptiveOnly)).toBe('max');
180
+ });
181
+ it('drops a level this model does not have', () => {
182
+ // The ceiling moved twice, so "does this model take effort?" was never
183
+ // a yes/no question. While it was modelled as one, `xhigh` on a 4.6 and
184
+ // `max` on a 4.5 went to the wire, and the vendor rejects an unknown
185
+ // level rather than clamping it.
186
+ const v46 = resolveThinkingCapability('claude-opus-4-6');
187
+ expect(resolveEffort('xhigh', { type: 'adaptive' }, v46)).toBeUndefined();
188
+ expect(resolveEffort('max', { type: 'adaptive' }, v46)).toBe('max');
189
+ const opus45 = resolveThinkingCapability('claude-opus-4-5');
190
+ expect(resolveEffort('max', { type: 'enabled' }, opus45)).toBeUndefined();
191
+ expect(resolveEffort('xhigh', { type: 'enabled' }, opus45)).toBeUndefined();
192
+ expect(resolveEffort('high', { type: 'enabled' }, opus45)).toBe('high');
193
+ });
194
+ it('takes every level on a current model', () => {
195
+ const opus5 = resolveThinkingCapability('claude-opus-5');
196
+ for (const level of ['low', 'medium', 'high', 'xhigh', 'max']) {
197
+ expect(resolveEffort(level, { type: 'adaptive' }, opus5), level).toBe(level);
198
+ }
125
199
  });
126
200
  });
127
201
  //# sourceMappingURL=thinking-capability.test.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"thinking-capability.test.js","sourceRoot":"","sources":["../../src/__tests__/thinking-capability.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AAE7C,OAAO,EACN,aAAa,EACb,mBAAmB,EACnB,yBAAyB,GACzB,MAAM,2BAA2B,CAAA;AAElC;;;;;;;;;;GAUG;AAEH,oDAAoD;AACpD,MAAM,KAAK,GAA4D;IACtE,CAAC,gBAAgB,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC;IAC5C,CAAC,iBAAiB,EAAE,IA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,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IACxE,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,sCAAsC,EAAE,GAAG,EAAE;QAC/C,MAAM,KAAK,GAAG,yBAAyB,CAAC,eAAe,CAAC,CAAA;QACxD,KAAK,MAAM,KAAK,IAAI,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,CAAU,EAAE,CAAC;YACxE,MAAM,CAAC,aAAa,CAAC,KAAK,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,KAAK,CAAC,EAAE,KAAK,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QAC7E,CAAC;IACF,CAAC,CAAC,CAAA;AACH,CAAC,CAAC,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=thinking-contract.live.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"thinking-contract.live.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/thinking-contract.live.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,97 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { resolveEffort, resolveThinkingBody, resolveThinkingCapability, } from '../thinking-capability.js';
3
+ /**
4
+ * The capability table, checked against the wire it describes.
5
+ *
6
+ * `thinking-capability.ts` encodes which thinking modes and which `effort`
7
+ * levels each model accepts. Every version of that table so far was
8
+ * transcribed from documentation, and the last transcription was wrong twice —
9
+ * it modelled `effort` as a boolean when the accepted levels are a set, so
10
+ * `xhigh` on a 4.6 and `max` on a 4.5 were forwarded to a wire that rejects an
11
+ * unknown level rather than clamping it.
12
+ *
13
+ * A table about a wire is only as good as the wire says it is. These tests ask.
14
+ *
15
+ * Skipped without a key. Deliberately narrow: two current models, cheap
16
+ * requests (`max_tokens: 1`), and only the rows that would silently rot.
17
+ */
18
+ const KEY = process.env.ANTHROPIC_API_KEY;
19
+ /** Cheap and current: one adaptive-only model, one manual-only model. */
20
+ const ADAPTIVE_MODEL = process.env.NAMZU_WIRE_TEST_MODEL ?? 'claude-sonnet-5';
21
+ const CAPPED_MODEL = 'claude-opus-5';
22
+ const MANUAL_MODEL = 'claude-haiku-4-5';
23
+ async function send(model, extra) {
24
+ const res = await fetch('https://api.anthropic.com/v1/messages', {
25
+ method: 'POST',
26
+ headers: {
27
+ 'x-api-key': KEY,
28
+ 'anthropic-version': '2023-06-01',
29
+ 'content-type': 'application/json',
30
+ },
31
+ body: JSON.stringify({
32
+ model,
33
+ max_tokens: 1,
34
+ messages: [{ role: 'user', content: 'hi' }],
35
+ ...extra,
36
+ }),
37
+ });
38
+ if (res.ok)
39
+ return true;
40
+ const body = await res.json().catch(() => ({}));
41
+ return body?.error?.message ?? `HTTP ${res.status}`;
42
+ }
43
+ describe.skipIf(!KEY)('the effort levels the table claims are the ones the wire takes', () => {
44
+ it.each(['low', 'medium', 'high', 'xhigh', 'max'])('%s is accepted on a current model, and the table says so', async (level) => {
45
+ const capability = resolveThinkingCapability(ADAPTIVE_MODEL);
46
+ expect(capability.effort, `table omits ${level}`).toContain(level);
47
+ const resolved = resolveEffort(level, { type: 'adaptive' }, capability);
48
+ expect(resolved, 'resolver dropped a level the table allows').toBe(level);
49
+ const result = await send(ADAPTIVE_MODEL, {
50
+ thinking: { type: 'adaptive' },
51
+ output_config: { effort: level },
52
+ });
53
+ expect(result).toBe(true);
54
+ }, 120_000);
55
+ it('drops effort on a model that takes none, and the wire agrees it would have failed', async () => {
56
+ const capability = resolveThinkingCapability(MANUAL_MODEL);
57
+ expect(capability.effort).toEqual([]);
58
+ expect(resolveEffort('high', { type: 'enabled' }, capability)).toBeUndefined();
59
+ // The half that matters: had the resolver NOT dropped it, this is what
60
+ // the wire would have said. A table claiming "no effort here" is only
61
+ // worth something if sending effort really does fail.
62
+ const result = await send(MANUAL_MODEL, { output_config: { effort: 'high' } });
63
+ expect(result).not.toBe(true);
64
+ }, 120_000);
65
+ });
66
+ describe.skipIf(!KEY)('the thinking body the resolver builds is one the wire accepts', () => {
67
+ it('adaptive, on a model the table calls adaptive-only', async () => {
68
+ const capability = resolveThinkingCapability(ADAPTIVE_MODEL);
69
+ expect(capability.adaptive).toBe(true);
70
+ const body = resolveThinkingBody({ type: 'adaptive' }, capability);
71
+ expect(await send(ADAPTIVE_MODEL, { thinking: body })).toBe(true);
72
+ }, 120_000);
73
+ it('rewrites a manual intent rather than sending one the model refuses', async () => {
74
+ // The resolver turns `enabled` into `adaptive` where manual is rejected.
75
+ // If it did not, this is the request that would go out — so both halves
76
+ // are asserted: what we send is accepted, and what we avoided is not.
77
+ const capability = resolveThinkingCapability(ADAPTIVE_MODEL);
78
+ const body = resolveThinkingBody({ type: 'enabled', budgetTokens: 2048 }, capability);
79
+ expect(body).toEqual({ type: 'adaptive' });
80
+ expect(await send(ADAPTIVE_MODEL, { thinking: body })).toBe(true);
81
+ expect(await send(ADAPTIVE_MODEL, { thinking: { type: 'enabled', budget_tokens: 2048 } })).not.toBe(true);
82
+ }, 120_000);
83
+ it('caps effort with thinking off only where the wire actually caps it', async () => {
84
+ // Both directions, because the first version of this rule was too wide.
85
+ const capped = resolveThinkingCapability(CAPPED_MODEL);
86
+ const disabledOnCapped = resolveThinkingBody({ type: 'disabled' }, capped);
87
+ expect(resolveEffort('max', disabledOnCapped, capped)).toBeUndefined();
88
+ expect(resolveEffort('high', disabledOnCapped, capped)).toBe('high');
89
+ expect(await send(CAPPED_MODEL, { thinking: disabledOnCapped, output_config: { effort: 'max' } })).not.toBe(true);
90
+ // …and a model the wire does NOT cap keeps the level the caller asked for.
91
+ const open = resolveThinkingCapability(ADAPTIVE_MODEL);
92
+ const disabledOnOpen = resolveThinkingBody({ type: 'disabled' }, open);
93
+ expect(resolveEffort('max', disabledOnOpen, open)).toBe('max');
94
+ expect(await send(ADAPTIVE_MODEL, { thinking: disabledOnOpen, output_config: { effort: 'max' } })).toBe(true);
95
+ }, 120_000);
96
+ });
97
+ //# sourceMappingURL=thinking-contract.live.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"thinking-contract.live.test.js","sourceRoot":"","sources":["../../src/__tests__/thinking-contract.live.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AAE7C,OAAO,EACN,aAAa,EACb,mBAAmB,EACnB,yBAAyB,GACzB,MAAM,2BAA2B,CAAA;AAElC;;;;;;;;;;;;;;GAcG;AAEH,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAA;AAEzC,yEAAyE;AACzE,MAAM,cAAc,GAAG,OAAO,CAAC,GAAG,CAAC,qBAAqB,IAAI,iBAAiB,CAAA;AAC7E,MAAM,YAAY,GAAG,eAAe,CAAA;AACpC,MAAM,YAAY,GAAG,kBAAkB,CAAA;AAEvC,KAAK,UAAU,IAAI,CAAC,KAAa,EAAE,KAA8B;IAChE,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,uCAAuC,EAAE;QAChE,MAAM,EAAE,MAAM;QACd,OAAO,EAAE;YACR,WAAW,EAAE,GAAa;YAC1B,mBAAmB,EAAE,YAAY;YACjC,cAAc,EAAE,kBAAkB;SAClC;QACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;YACpB,KAAK;YACL,UAAU,EAAE,CAAC;YACb,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;YAC3C,GAAG,KAAK;SACR,CAAC;KACF,CAAC,CAAA;IACF,IAAI,GAAG,CAAC,EAAE;QAAE,OAAO,IAAI,CAAA;IACvB,MAAM,IAAI,GAAY,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;IACxD,OAAQ,IAAgD,EAAE,KAAK,EAAE,OAAO,IAAI,QAAQ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Q,EAAE,cAAc,EAAE,aAAa,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC,CAC1F,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACb,CAAC,EAAE,OAAO,CAAC,CAAA;AACZ,CAAC,CAAC,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=wire-contract.live.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wire-contract.live.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/wire-contract.live.test.ts"],"names":[],"mappings":""}