@namzu/anthropic 2.0.1 → 3.0.1

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.
Files changed (29) hide show
  1. package/CHANGELOG.md +122 -0
  2. package/dist/__tests__/background-delegation.live.test.d.ts +2 -0
  3. package/dist/__tests__/background-delegation.live.test.d.ts.map +1 -0
  4. package/dist/__tests__/background-delegation.live.test.js +212 -0
  5. package/dist/__tests__/background-delegation.live.test.js.map +1 -0
  6. package/dist/__tests__/thinking-capability.test.js +49 -21
  7. package/dist/__tests__/thinking-capability.test.js.map +1 -1
  8. package/dist/__tests__/thinking-contract.live.test.d.ts +2 -0
  9. package/dist/__tests__/thinking-contract.live.test.d.ts.map +1 -0
  10. package/dist/__tests__/thinking-contract.live.test.js +97 -0
  11. package/dist/__tests__/thinking-contract.live.test.js.map +1 -0
  12. package/dist/__tests__/wire-contract.live.test.d.ts +2 -0
  13. package/dist/__tests__/wire-contract.live.test.d.ts.map +1 -0
  14. package/dist/__tests__/wire-contract.live.test.js +254 -0
  15. package/dist/__tests__/wire-contract.live.test.js.map +1 -0
  16. package/dist/client.d.ts.map +1 -1
  17. package/dist/client.js +15 -3
  18. package/dist/client.js.map +1 -1
  19. package/dist/thinking-capability.d.ts +26 -6
  20. package/dist/thinking-capability.d.ts.map +1 -1
  21. package/dist/thinking-capability.js +73 -16
  22. package/dist/thinking-capability.js.map +1 -1
  23. package/package.json +3 -3
  24. package/src/__tests__/background-delegation.live.test.ts +243 -0
  25. package/src/__tests__/thinking-capability.test.ts +51 -22
  26. package/src/__tests__/thinking-contract.live.test.ts +125 -0
  27. package/src/__tests__/wire-contract.live.test.ts +312 -0
  28. package/src/client.ts +18 -2
  29. package/src/thinking-capability.ts +89 -16
package/CHANGELOG.md CHANGED
@@ -1,5 +1,127 @@
1
1
  # Changelog
2
2
 
3
+ ## 3.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 062624c: `effort` can be set on a run — and so, for the first time, can `thinking`.
8
+
9
+ `effort` was on the provider params, exported, and read by a driver that wrote
10
+ it to the wire, and nothing in the kernel ever set it. Every request went out at
11
+ the model's default, which reads as "this model ignores effort" rather than
12
+ "nobody plumbed it through".
13
+
14
+ `AgentRunConfig` gains `effort`, a sibling of `thinking` rather than a field
15
+ inside it — on some models the two are independent controls that apply together,
16
+ and nesting would make that combination unsayable. It is run-level rather than
17
+ per-step because the provider documents that changing effort between requests
18
+ does not preserve a cached prefix, so a value that moves between steps buys a
19
+ different answer shape at the cost of the cache on every step that changes it.
20
+
21
+ **`thinking` turned out to have the same defect, and had shipped with it.** It
22
+ was settable only through `drainQuery`. Every ergonomic entry point — `runAgent`,
23
+ `ReactiveAgent`, `SupervisorAgent`, and the agent manager's bare-config branch —
24
+ builds its run config by hand-listing fields, so a field nobody remembered to add
25
+ is dropped in silence, with no cast to blame and no error to see. A caller could
26
+ set `thinking` on an agent config and get a run that never asked for it. Both
27
+ fields now live on `BaseAgentConfig` and are forwarded by all four.
28
+
29
+ This was found by watching an actual HTTP body from a real run. The unit tests
30
+ passed throughout, because they drive the kernel directly, and the kernel was
31
+ never the half that was broken.
32
+
33
+ **A driver that cannot honour `effort` now refuses rather than dropping it**,
34
+ the rule `thinking` already had. Effort is the worse silence of the two: a
35
+ dropped `thinking` leaves an empty reasoning list someone might notice, while a
36
+ dropped `effort` leaves a perfectly ordinary answer, so a run requested at `max`
37
+ is indistinguishable from one at the default — including in what it cost.
38
+ Nothing existing breaks, because the field could not be set until now.
39
+
40
+ Two driver-side corrections ride along, both verified against the live wire:
41
+
42
+ - The preview model's capability row claimed all five effort levels. It takes
43
+ `max` and not `xhigh`. That model is not reachable from the tenant the live
44
+ suite runs against, so the row is sourced from the reference rather than
45
+ measured — but the pairing itself is now measured, on a model that has it:
46
+ `claude-sonnet-4-6` answers `xhigh` with _"This model does not support effort
47
+ level 'xhigh'. Supported levels: high, low, max, medium"_ and accepts `max`.
48
+ Reading the levels as a ladder, where anything taking the top rung takes the
49
+ one below, is what produced the wrong row.
50
+ - `output_config` is now merged rather than assigned. It is a shared envelope on
51
+ that wire — a structured-output format and a task budget live in it too — so
52
+ assigning meant whoever wired the next one would silently delete effort, or
53
+ have effort delete theirs, depending only on which line ran last.
54
+
55
+ ## 3.0.0
56
+
57
+ ### Major Changes
58
+
59
+ - f8355de: tool schemas are rendered in the dialect each wire actually parses
60
+
61
+ A tool with a tuple-shaped field took down every request that offered it. The
62
+ kernel renders one canonical JSON Schema in draft-07, where a tuple is
63
+ `items: [a, b]`; one of the wires namzu speaks validates tool input as JSON
64
+ Schema 2020-12, where that spelling is invalid and a tuple must be
65
+ `prefixItems`. Every driver forwarded the rendering verbatim, so the built-in
66
+ `read` tool — whose `readRange` is a Zod tuple — produced a 400 that rejected
67
+ the **whole** request, taking every other tool in the call down with it. The
68
+ turn died before generating a token.
69
+
70
+ The failure had nothing to do with strict tool use, which is why the guard
71
+ added for the previous schema outage never saw it: it fires with strict
72
+ validation unset, and with strict on the dialect error arrives _first_.
73
+
74
+ Which dialect a wire parses is a property of the wire, so the conversion now
75
+ happens at each driver's boundary rather than in the renderer:
76
+
77
+ ```ts
78
+ import { toSchemaDialect, findDraft07Only } from "@namzu/sdk";
79
+
80
+ toSchemaDialect(schema, "2020-12"); // items: [a, b] -> prefixItems: [a, b]
81
+ findDraft07Only(schema); // paths that no 2020-12 parser will accept
82
+ ```
83
+
84
+ `renderToolSchema` is exported now too, so a caller assembling its own tool
85
+ payload gets the same memoized, `$schema`-stripped, deep-frozen rendering the
86
+ kernel puts on the wire — byte-identical across iterations, which matters
87
+ because the tools block sits at position 0 of the prompt-cache prefix.
88
+
89
+ `ToolCatalog` used to convert schemas through its own inline call with the same
90
+ options. Same output, none of the guarantees: no `$schema` stripping, no
91
+ memoization, no freeze. It goes through `renderToolSchema` now.
92
+
93
+ **Breaking, for the three drivers.** Their `@namzu/sdk` peer range was
94
+ `>=1.3.0` and is now `>=6.0.0`. That range was already wrong — the drivers call
95
+ kernel functions added well after 1.3.0 — and it would now let a package
96
+ manager install a combination that throws on every request carrying a tool.
97
+ Upgrade the kernel alongside the driver.
98
+
99
+ The conversion follows the model on multi-vendor wires. Bedrock's Converse API
100
+ carries several vendors through one request shape, and the 2020-12 requirement
101
+ was measured on one of them, so schemas bound for the others are left in the
102
+ dialect they were rendered in. Guessing there would trade a known break for an
103
+ unmeasured one.
104
+
105
+ ### Patch Changes
106
+
107
+ - f8355de: reasoning effort is dropped only on the models that actually refuse it
108
+
109
+ With thinking switched off, the driver discarded `xhigh` and `max` on every
110
+ model that can switch thinking off. The reasoning was that the pairing is
111
+ incoherent anyway — asking a model not to think and then to think as hard as
112
+ possible.
113
+
114
+ Measured against the live API, the rule was too wide. One model family rejects
115
+ that combination with _"effort is not supported when thinking is disabled"_;
116
+ its siblings accept it and honour the effort. So the blanket rule was silently
117
+ discarding a setting the caller asked for and the wire would have applied, on
118
+ models where nothing was wrong.
119
+
120
+ Looking incoherent is not the same as being rejected, and only the wire decides
121
+ which. The capability table now carries the levels accepted with thinking off
122
+ as a separate set from the levels accepted generally, because on most models
123
+ those two sets are identical and on one family they are not.
124
+
3
125
  ## 2.0.1
4
126
 
5
127
  ### Patch Changes
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=background-delegation.live.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"background-delegation.live.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/background-delegation.live.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,212 @@
1
+ import { CompletionInbox, ToolRegistry, buildCoordinatorTools, drainQuery, runAgent, } from '@namzu/sdk';
2
+ import { describe, expect, it } from 'vitest';
3
+ import { AnthropicProvider } from '../client.js';
4
+ /**
5
+ * Does a real model actually receive a worker it stopped waiting for?
6
+ *
7
+ * Everything else about this mechanism is tested against fakes: the inbox
8
+ * queues what nobody claimed, the tools claim what they deliver, the loop
9
+ * drains the rest into the transcript. All of it can be true and the feature
10
+ * still useless, because the part that decides whether it works is whether a
11
+ * MODEL reads the notification and acts on it — and no fake can answer that.
12
+ *
13
+ * So this runs the whole thing against the live API: a real supervisor model,
14
+ * a real worker model, a background launch, and an assertion that the answer
15
+ * the supervisor finally gives contains something only the worker knew.
16
+ *
17
+ * The gateway here is deliberately hand-rolled over `runAgent` rather than
18
+ * the kernel's `LocalTaskGateway`. That is the shape a host implements, so it
19
+ * doubles as proof that the inbox needs nothing from a gateway beyond the
20
+ * `onTaskCompleted` every gateway already has.
21
+ *
22
+ * Skipped without a key. Run with:
23
+ *
24
+ * ANTHROPIC_API_KEY=… pnpm --filter @namzu/anthropic test
25
+ */
26
+ const KEY = process.env.ANTHROPIC_API_KEY;
27
+ const MODEL = process.env.NAMZU_WIRE_TEST_MODEL ?? 'claude-haiku-4-5';
28
+ /** The fact only the worker can know, so its presence proves delivery. */
29
+ const SECRET = 'PELICAN-7731';
30
+ function provider() {
31
+ return new AnthropicProvider({ apiKey: KEY, model: MODEL });
32
+ }
33
+ /**
34
+ * A host-shaped gateway: spawns a real child run per task and announces it.
35
+ *
36
+ * Nothing here is kernel code. It implements `TaskGateway` the way an
37
+ * embedding application does, which is the point — the inbox attaches to it
38
+ * unchanged.
39
+ */
40
+ function liveGateway() {
41
+ const handles = new Map();
42
+ const settled = new Map();
43
+ const listeners = new Set();
44
+ let seq = 0;
45
+ return {
46
+ async createTask({ agentId, prompt }) {
47
+ seq += 1;
48
+ const taskId = `tsk_live_${seq}`;
49
+ const handle = {
50
+ taskId: taskId,
51
+ agentId,
52
+ state: 'running',
53
+ createdAt: Date.now(),
54
+ };
55
+ handles.set(taskId, handle);
56
+ settled.set(taskId, runAgent({
57
+ provider: provider(),
58
+ model: MODEL,
59
+ prompt,
60
+ instructions: 'Answer in one short sentence. Do not explain yourself.',
61
+ maxIterations: 2,
62
+ tokenBudget: 20_000,
63
+ }).then((run) => {
64
+ const done = {
65
+ ...handle,
66
+ state: 'completed',
67
+ completedAt: Date.now(),
68
+ result: {
69
+ status: 'completed',
70
+ result: run.output ?? '',
71
+ },
72
+ };
73
+ handles.set(taskId, done);
74
+ for (const cb of listeners)
75
+ cb(done);
76
+ return done;
77
+ }));
78
+ return handle;
79
+ },
80
+ waitForTask: async (taskId) => {
81
+ const pending = settled.get(taskId);
82
+ if (!pending)
83
+ throw new Error(`no task ${taskId}`);
84
+ return pending;
85
+ },
86
+ continueTask: async () => undefined,
87
+ cancelTask: () => undefined,
88
+ getTask: (taskId) => handles.get(taskId),
89
+ listTasks: () => [...handles.values()],
90
+ onTaskCompleted: (cb) => {
91
+ listeners.add(cb);
92
+ return () => listeners.delete(cb);
93
+ },
94
+ };
95
+ }
96
+ describe.skipIf(!KEY)('a background worker reaches a real supervisor', () => {
97
+ it('delivers the result through the transcript, with no polling', async () => {
98
+ const gateway = liveGateway();
99
+ const inbox = new CompletionInbox();
100
+ inbox.attach(gateway);
101
+ const tools = new ToolRegistry();
102
+ for (const tool of buildCoordinatorTools({
103
+ gateway,
104
+ completionInbox: inbox,
105
+ workingDirectory: process.cwd(),
106
+ allowedAgentIds: ['lookup'],
107
+ })) {
108
+ tools.register(tool);
109
+ }
110
+ const run = await drainQuery({
111
+ provider: provider(),
112
+ tools,
113
+ completionInbox: inbox,
114
+ agentId: 'supervisor',
115
+ agentName: 'Supervisor',
116
+ messages: [
117
+ {
118
+ role: 'user',
119
+ content: [
120
+ 'Delegate to the "lookup" agent, in the BACKGROUND (background: true), this exact prompt:',
121
+ `"Reply with exactly this token and nothing else: ${SECRET}"`,
122
+ '',
123
+ 'Do not wait for it with wait_for_task and do not list tasks in a loop.',
124
+ 'After launching it, just say "launched" and stop.',
125
+ 'Its result will arrive on its own; when it does, reply with the token you received.',
126
+ ].join('\n'),
127
+ timestamp: Date.now(),
128
+ },
129
+ ],
130
+ workingDirectory: process.cwd(),
131
+ runConfig: {
132
+ model: MODEL,
133
+ timeoutMs: 180_000,
134
+ tokenBudget: 200_000,
135
+ maxIterations: 6,
136
+ maxResponseTokens: 1_024,
137
+ },
138
+ sessionId: 'ses_live_delegation',
139
+ threadId: 'thd_live_delegation',
140
+ projectId: 'prj_live_delegation',
141
+ tenantId: 'tnt_live_delegation',
142
+ });
143
+ const transcript = run.messages
144
+ .filter((m) => m.role === 'user')
145
+ .map((m) => (typeof m.content === 'string' ? m.content : JSON.stringify(m.content)))
146
+ .join('\n');
147
+ // 1. The notification actually landed in the supervisor's transcript.
148
+ expect(transcript, 'no task-notification reached the transcript').toContain('task-notification');
149
+ expect(transcript).toContain(SECRET);
150
+ // 2. The model read it. This is the half no fake can establish: the
151
+ // worker's token appears in the supervisor's own final answer, and
152
+ // the supervisor never had it any other way.
153
+ expect(run.result ?? '', 'the supervisor never used what it was told').toContain(SECRET);
154
+ // 3. It got there without polling, which is the whole complaint the
155
+ // fix answers — `agent_task_list` in a sleep loop was the only move
156
+ // on the board before this.
157
+ const listCalls = (run.steps ?? [])
158
+ .flatMap((s) => s.toolCalls ?? [])
159
+ .filter((c) => c.function.name === 'agent_task_list');
160
+ expect(listCalls.length, 'the model still had to poll').toBe(0);
161
+ }, 300_000);
162
+ it('still delivers the result inline when the launch is not backgrounded', async () => {
163
+ // The path `dc16d58` protects: a blocking launch answers as its own
164
+ // tool_result, and must NOT also arrive as an envelope.
165
+ const gateway = liveGateway();
166
+ const inbox = new CompletionInbox();
167
+ inbox.attach(gateway);
168
+ const tools = new ToolRegistry();
169
+ for (const tool of buildCoordinatorTools({
170
+ gateway,
171
+ completionInbox: inbox,
172
+ workingDirectory: process.cwd(),
173
+ allowedAgentIds: ['lookup'],
174
+ })) {
175
+ tools.register(tool);
176
+ }
177
+ const run = await drainQuery({
178
+ provider: provider(),
179
+ tools,
180
+ completionInbox: inbox,
181
+ agentId: 'supervisor',
182
+ agentName: 'Supervisor',
183
+ messages: [
184
+ {
185
+ role: 'user',
186
+ content: `Use create_task on the "lookup" agent with this prompt: "Reply with exactly this token and nothing else: ${SECRET}". Do NOT set background. Then report the token it returned.`,
187
+ timestamp: Date.now(),
188
+ },
189
+ ],
190
+ workingDirectory: process.cwd(),
191
+ runConfig: {
192
+ model: MODEL,
193
+ timeoutMs: 180_000,
194
+ tokenBudget: 200_000,
195
+ maxIterations: 6,
196
+ maxResponseTokens: 1_024,
197
+ },
198
+ sessionId: 'ses_live_delegation',
199
+ threadId: 'thd_live_delegation',
200
+ projectId: 'prj_live_delegation',
201
+ tenantId: 'tnt_live_delegation',
202
+ });
203
+ expect(run.result ?? '').toContain(SECRET);
204
+ const transcript = run.messages
205
+ .filter((m) => m.role === 'user')
206
+ .map((m) => (typeof m.content === 'string' ? m.content : JSON.stringify(m.content)))
207
+ .join('\n');
208
+ // Delivered once, as a tool_result — no duplicate envelope.
209
+ expect(transcript, 'the blocking result was announced a second time').not.toContain('task-notification');
210
+ }, 300_000);
211
+ });
212
+ //# sourceMappingURL=background-delegation.live.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"background-delegation.live.test.js","sourceRoot":"","sources":["../../src/__tests__/background-delegation.live.test.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,eAAe,EACf,YAAY,EACZ,qBAAqB,EACrB,UAAU,EACV,QAAQ,GACR,MAAM,YAAY,CAAA;AAEnB,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AAE7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAEhD;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAA;AACzC,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,qBAAqB,IAAI,kBAAkB,CAAA;AAErE,0EAA0E;AAC1E,MAAM,MAAM,GAAG,cAAc,CAAA;AAE7B,SAAS,QAAQ;IAChB,OAAO,IAAI,iBAAiB,CAAC,EAAE,MAAM,EAAE,GAAa,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAA;AACtE,CAAC;AAED;;;;;;GAMG;AACH,SAAS,WAAW;IACnB,MAA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ice, so a boolean could not say that `xhigh` is rejected on 4.6 and `max`
26
26
  * is rejected on 4.5 — which is exactly what it failed to say.
27
27
  */
28
+ const CAPPED = BASE; // opus 5+ with thinking off
28
29
  const TABLE = [
29
30
  // Always-on families: thinking cannot be switched off at any version.
30
- ['claude-fable-5', true, false, false, ALL],
31
- ['claude-mythos-5', true, false, false, ALL],
32
- ['claude-mythos-preview', true, true, false, ALL],
31
+ ['claude-fable-5', true, false, false, ALL, ALL],
32
+ ['claude-mythos-5', true, false, false, ALL, ALL],
33
+ // The preview takes `max` and NOT `xhigh`, which is the pairing it is easy
34
+ // to assume away — the reference says outright that some models supporting
35
+ // `max` do not support `xhigh`, and this is one. Reading the levels as a
36
+ // ladder is what put ALL on this row originally, and a ladder reading sends
37
+ // a level the wire rejects.
38
+ ['claude-mythos-preview', true, true, false, NO_XHIGH, NO_XHIGH],
33
39
  // 4.7 and later: adaptive only, and it can still be disabled.
34
- ['claude-opus-5', true, false, true, ALL],
35
- ['claude-sonnet-5', true, false, true, ALL],
36
- ['claude-opus-4-8', true, false, true, ALL],
37
- ['claude-opus-4-7', true, false, true, ALL],
40
+ ['claude-opus-5', true, false, true, ALL, CAPPED],
41
+ ['claude-sonnet-5', true, false, true, ALL, ALL],
42
+ ['claude-opus-4-8', true, false, true, ALL, ALL],
43
+ ['claude-opus-4-7', true, false, true, ALL, ALL],
38
44
  // 4.6: both modes, manual deprecated but working — and no `xhigh`.
39
- ['claude-opus-4-6', true, true, true, NO_XHIGH],
40
- ['claude-sonnet-4-6', true, true, true, NO_XHIGH],
45
+ ['claude-opus-4-6', true, true, true, NO_XHIGH, NO_XHIGH],
46
+ ['claude-sonnet-4-6', true, true, true, NO_XHIGH, NO_XHIGH],
41
47
  // 4.5 and earlier: manual only. Opus 4.5 is the one that takes effort,
42
48
  // and only the first three levels.
43
- ['claude-opus-4-5', false, true, true, BASE],
44
- ['claude-haiku-4-5', false, true, true, NONE],
45
- ['claude-sonnet-4-5', false, true, true, NONE],
46
- ['claude-opus-4-1', false, true, true, NONE],
49
+ ['claude-opus-4-5', false, true, true, BASE, BASE],
50
+ ['claude-haiku-4-5', false, true, true, NONE, NONE],
51
+ ['claude-sonnet-4-5', false, true, true, NONE, NONE],
52
+ ['claude-opus-4-1', false, true, true, NONE, NONE],
47
53
  ];
48
54
  describe('what each model accepts', () => {
49
- for (const [model, adaptive, manual, canDisable, effort] of TABLE) {
55
+ for (const [model, adaptive, manual, canDisable, effort, effortWhenDisabled] of TABLE) {
50
56
  it(`resolves ${model}`, () => {
51
- expect(resolveThinkingCapability(model)).toEqual({ adaptive, manual, canDisable, effort });
57
+ expect(resolveThinkingCapability(model)).toEqual({
58
+ adaptive,
59
+ manual,
60
+ canDisable,
61
+ effort,
62
+ effortWhenDisabled,
63
+ });
52
64
  });
53
65
  }
54
66
  it('tolerates a vendor prefix and a date suffix', () => {
@@ -85,6 +97,7 @@ describe('what each model accepts', () => {
85
97
  manual: true,
86
98
  canDisable: true,
87
99
  effort: [],
100
+ effortWhenDisabled: [],
88
101
  });
89
102
  });
90
103
  });
@@ -148,12 +161,27 @@ describe('when effort rides along', () => {
148
161
  const opus45 = resolveThinkingCapability('claude-opus-4-5');
149
162
  expect(resolveEffort('high', { type: 'enabled', budget_tokens: 8000 }, opus45)).toBe('high');
150
163
  });
151
- it('refuses the combination the vendor rejects', () => {
152
- // Thinking off at effort xhigh/max is a 400 on Opus 5 and later, and
153
- // is incoherent anyway: do not think, and think as hard as possible.
154
- expect(resolveEffort('xhigh', { type: 'disabled' }, adaptiveOnly)).toBeUndefined();
155
- expect(resolveEffort('max', { type: 'disabled' }, adaptiveOnly)).toBeUndefined();
156
- expect(resolveEffort('high', { type: 'disabled' }, adaptiveOnly)).toBe('high');
164
+ it('caps effort with thinking off only where the wire caps it', () => {
165
+ // This rule used to be blanket: thinking off at `xhigh`/`max` was
166
+ // refused on every model that can disable thinking, reasoning that the
167
+ // pairing is incoherent anyway. Measured against the live API, that was
168
+ // too wide — only the Opus 5 family rejects it:
169
+ //
170
+ // claude-opus-5 + disabled + max -> 400 "not supported when thinking is disabled"
171
+ // claude-sonnet-5 + disabled + max -> accepted
172
+ // claude-opus-4-8 + disabled + max -> accepted
173
+ //
174
+ // So the blanket rule was dropping an effort the caller asked for and
175
+ // the wire would have honoured. Looking incoherent is not the same as
176
+ // being rejected, and only the wire decides which.
177
+ const opus5 = resolveThinkingCapability('claude-opus-5');
178
+ expect(resolveEffort('max', { type: 'disabled' }, opus5)).toBeUndefined();
179
+ expect(resolveEffort('xhigh', { type: 'disabled' }, opus5)).toBeUndefined();
180
+ expect(resolveEffort('high', { type: 'disabled' }, opus5)).toBe('high');
181
+ // …and uncapped with thinking on, on the same model.
182
+ expect(resolveEffort('max', { type: 'adaptive' }, opus5)).toBe('max');
183
+ // `adaptiveOnly` here is Sonnet 5, which the wire does not cap.
184
+ expect(resolveEffort('max', { type: 'disabled' }, adaptiveOnly)).toBe('max');
157
185
  });
158
186
  it('drops a level this model does not have', () => {
159
187
  // The ceiling moved twice, so "does this model take effort?" was never
@@ -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,MAAM,GAAG,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,CAAA;AACrD,gEAAgE;AAChE,MAAM,QAAQ,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,CAAC,CAAA;AACjD,uBAAuB;AACvB,MAAM,IAAI,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAA;AACtC,MAAM,IAAI,GAAa,EAAE,C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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,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AA;QAC1E,MAAM,CAAC,aAAa,CAAC,KAAK,EAAE,gBAAgB,EAAE,MAAM,CAAC,CAAC,CAAC,aAAa,EAAE,CAAA;QACtE,MAAM,CAAC,aAAa,CAAC,MAAM,EAAE,gBAAgB,EAAE,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QACpE,MAAM,CACL,MAAM,IAAI,CAAC,YAAY,EAAE,EAAE,QAAQ,EAAE,gBAAgB,EAAE,aAAa,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC,CAC1F,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QAEhB,2EAA2E;QAC3E,MAAM,IAAI,GAAG,yBAAyB,CAAC,cAAc,CAAC,CAAA;QACtD,MAAM,cAAc,GAAG,mBAAmB,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,IAAI,CAAC,CAAA;QACtE,MAAM,CAAC,aAAa,CAAC,KAAK,EAAE,cAAc,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QAC9D,MAAM,CACL,MAAM,IAAI,CAAC,cAAc,EAAE,EAAE,QAAQ,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":""}