@namzu/anthropic 6.1.0 → 6.2.2

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.
@@ -1,4 +1,5 @@
1
1
  import { parseVersionedModelId } from '@namzu/sdk';
2
+ import { reachesFloor } from './version-floor.js';
2
3
  const NO_EFFORT = [];
3
4
  /** Everything from 4.7 onward, plus the always-on families. */
4
5
  const FULL_EFFORT = ['low', 'medium', 'high', 'xhigh', 'max'];
@@ -13,6 +14,46 @@ const MANUAL_ONLY = {
13
14
  effort: NO_EFFORT,
14
15
  effortWhenDisabled: NO_EFFORT,
15
16
  };
17
+ /**
18
+ * Thinking is always on: adaptive only, never off, every effort level.
19
+ *
20
+ * `effortWhenDisabled` is the full set because nothing is ever sent disabled
21
+ * here — `resolveThinkingBody` omits that intent on these models — so a
22
+ * caller asking for the levels under a `disabled` intent gets the levels the
23
+ * request will actually carry.
24
+ */
25
+ const ALWAYS_ON = {
26
+ adaptive: true,
27
+ manual: false,
28
+ canDisable: false,
29
+ effort: FULL_EFFORT,
30
+ effortWhenDisabled: FULL_EFFORT,
31
+ };
32
+ /**
33
+ * Where thinking stops being optional, per family.
34
+ *
35
+ * Data rather than a branch per model. The vendor lists the models that answer
36
+ * `thinking: {type: "disabled"}` with a 400 — Fable 5.1, Mythos 5.1, Fable 5,
37
+ * Mythos 5, Opus 5.5 and Mythos Preview — and the list is two whole families
38
+ * plus Opus from 5.5. Opus crossed at a minor version: `claude-opus-5` takes
39
+ * `disabled` at effort `high` or below, `claude-opus-5-5` refuses it at every
40
+ * level.
41
+ *
42
+ * That crossing is why this is a table. The version fallback below reads every
43
+ * newer id in an adaptive family as able to switch thinking off, so the first
44
+ * always-on Opus resolved to `canDisable: true` and a shared `disabled` intent
45
+ * went out verbatim and came back 400 — on a config that worked on the model
46
+ * one minor below. The next family to cross is one row here, and a later
47
+ * version of a family that has crossed is covered without one.
48
+ *
49
+ * Mythos Preview is not a row: it carries no version to compare, and it keeps
50
+ * manual mode, so `resolveThinkingCapability` resolves it by name.
51
+ */
52
+ const ALWAYS_ON_FROM = [
53
+ { family: 'fable', major: 0, minor: 0 },
54
+ { family: 'mythos', major: 0, minor: 0 },
55
+ { family: 'opus', major: 5, minor: 5 },
56
+ ];
16
57
  /**
17
58
  * The vocabulary this driver's ids are spelled in.
18
59
  *
@@ -69,24 +110,20 @@ export function resolveThinkingCapability(model) {
69
110
  if (!parsed)
70
111
  return MANUAL_ONLY;
71
112
  const { family, major, minor } = parsed;
72
- // Always-on families: thinking cannot be disabled at any version.
73
- if (family === 'fable' || family === 'mythos') {
74
- return {
75
- adaptive: true,
76
- manual: false,
77
- canDisable: false,
78
- effort: FULL_EFFORT,
79
- effortWhenDisabled: FULL_EFFORT,
80
- };
81
- }
113
+ // Thinking cannot be disabled from here on, whatever the effort level.
114
+ // Checked before the version fallback, which would otherwise read the id
115
+ // as a newer adaptive model that can switch thinking off.
116
+ if (reachesFloor(parsed, ALWAYS_ON_FROM))
117
+ return ALWAYS_ON;
82
118
  // 4.7 and later dropped manual mode outright.
83
119
  if (major > 4 || (major === 4 && minor >= 7)) {
84
- // The Opus 5 family alone caps effort while thinking is off. Measured,
85
- // not inferred: `claude-opus-5` refuses `disabled` + `xhigh`/`max` and
120
+ // Opus 5 alone caps effort while thinking is off. Measured, not
121
+ // inferred: `claude-opus-5` refuses `disabled` + `xhigh`/`max` and
86
122
  // accepts `disabled` + `high`, while `claude-sonnet-5` and
87
123
  // `claude-opus-4-8` accept `disabled` + `max`. A version comparison of
88
124
  // "5 and later" would have caught Sonnet 5 too and dropped an effort
89
- // that wire honours.
125
+ // that wire honours. Opus from 5.5 never reaches this line: it cannot
126
+ // switch thinking off at all, and returned above.
90
127
  const opus5Plus = family === 'opus' && major >= 5;
91
128
  return {
92
129
  adaptive: true,
@@ -1 +1 @@
1
- {"version":3,"file":"thinking-capability.js","sourceRoot":"","sources":["../src/thinking-capability.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAA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,KAAK,CAAC,CAAC,CAAC,cAAc,KAAK,GAAG,CAAC,CAAC,CAAC,qCAAqC,CAAA;IACrF,MAAM,OAAO,GAAG,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAA;IAChE,MAAM,IAAI,KAAK,CACd,8BAA8B,MAAM,qBAAqB,MAAM,uBAAuB,OAAO,kDAAkD,CAC/I,CAAA;AACF,CAAC"}
@@ -0,0 +1,26 @@
1
+ import type { ThinkingConfig, ToolChoice } from '@namzu/sdk';
2
+ import { type ResolvedThinkingBody } from './thinking-capability.js';
3
+ /**
4
+ * Whether this model takes a forced tool choice — `toolChoice: 'required'` or
5
+ * a named function — under the thinking configuration you intend to send.
6
+ *
7
+ * Built from the same resolution the request path uses, so a caller deciding
8
+ * whether to force a step and the request it then sends cannot disagree.
9
+ * `false` means the driver will refuse that request before sending it; use
10
+ * `toolChoice: 'auto'` and say in the prompt which tool to call.
11
+ */
12
+ export declare function acceptsForcedToolChoice(model: string, thinking?: ThinkingConfig): boolean;
13
+ /**
14
+ * Refuse, before transport, a forced tool choice the vendor is certain to reject.
15
+ *
16
+ * The same trade `resolveEffort` makes for an effort level. Sending it costs a
17
+ * round trip to learn what is already known here. Quietly sending `auto`
18
+ * instead would be worse: a forced choice is a contract that the model calls a
19
+ * tool, and a caller relying on it — a step that must produce a structured
20
+ * answer — would get prose back and be told the request succeeded.
21
+ *
22
+ * The error is the `bad_request` `ProviderRequestError` the vendor's 400 would
23
+ * have become, with its own code, so a caller's handling does not change.
24
+ */
25
+ export declare function assertForcedToolChoiceAccepted(toolChoice: ToolChoice | undefined, thinkingBody: ResolvedThinkingBody, model: string): void;
26
+ //# sourceMappingURL=tool-choice.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-choice.d.ts","sourceRoot":"","sources":["../src/tool-choice.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAE5D,OAAO,EAEN,KAAK,oBAAoB,EAGzB,MAAM,0BAA0B,CAAA;AA0DjC;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,cAAc,GAAG,OAAO,CAGzF;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,8BAA8B,CAC7C,UAAU,EAAE,UAAU,GAAG,SAAS,EAClC,YAAY,EAAE,oBAAoB,EAClC,KAAK,EAAE,MAAM,GACX,IAAI,CAaN"}
@@ -0,0 +1,93 @@
1
+ import { ProviderRequestError, parseVersionedModelId } from '@namzu/sdk';
2
+ import { MODEL_ID_GRAMMAR, resolveThinkingBody, resolveThinkingCapability, } from './thinking-capability.js';
3
+ import { reachesFloor } from './version-floor.js';
4
+ /**
5
+ * Models that refuse a forced tool choice whatever the thinking settings.
6
+ *
7
+ * `tool_choice: {type: "any"}` and `{type: "tool", name}` come back 400 —
8
+ * `tool_choice: type "tool" and "any" are not supported for this model.` — on
9
+ * Claude Opus 5.5, Claude Fable 5.1 and Claude Mythos 5.1, and on the
10
+ * token-counting endpoint too. That list is the vendor's, stated identically
11
+ * in its error reference and in the "Forcing tool use" table of its tool
12
+ * definition page. Opus 5 and Fable 5 still take a forced choice, so these are
13
+ * version floors and not family rules — and not the always-on line in
14
+ * `thinking-capability.ts` either: Fable 5 cannot stop thinking and accepts a
15
+ * forced choice all the same.
16
+ *
17
+ * SOURCED, NOT MEASURED. The wire has not been asked from here; the live
18
+ * contract suite carries the probe for when a key is present. Mythos Preview
19
+ * is deliberately absent: neither vendor page names it, and this table holds
20
+ * what the vendor says, not what seems likely.
21
+ */
22
+ const REFUSES_FORCED_TOOL_CHOICE_FROM = [
23
+ { family: 'opus', major: 5, minor: 5 },
24
+ { family: 'fable', major: 5, minor: 1 },
25
+ { family: 'mythos', major: 5, minor: 1 },
26
+ ];
27
+ /** `'required'` or a named function: the two choices that make a call mandatory. */
28
+ function isForced(toolChoice) {
29
+ return (toolChoice === 'required' || (typeof toolChoice === 'object' && toolChoice.type === 'function'));
30
+ }
31
+ /**
32
+ * Why a forced choice would be refused for this model and thinking body, or
33
+ * `undefined` when it would be taken.
34
+ *
35
+ * Two causes, both from the vendor's table. The model may refuse it outright.
36
+ * Or the request may carry manual extended thinking — `thinking: {type:
37
+ * "enabled"}` — which rejects a forced choice on every model that has it.
38
+ * Adaptive thinking does not: Opus 5 takes a forced choice with thinking on.
39
+ *
40
+ * The second is decided on the RESOLVED body, not on the caller's intent,
41
+ * because that is what the vendor sees: an `adaptive` intent becomes `enabled`
42
+ * on a manual-only model, and an `enabled` intent becomes `adaptive` on an
43
+ * adaptive-only one.
44
+ */
45
+ function forcedToolChoiceRefusal(model, thinkingBody) {
46
+ const version = parseVersionedModelId(model, MODEL_ID_GRAMMAR);
47
+ if (version && reachesFloor(version, REFUSES_FORCED_TOOL_CHOICE_FROM))
48
+ return 'model';
49
+ if (thinkingBody?.type === 'enabled')
50
+ return 'manual-thinking';
51
+ return undefined;
52
+ }
53
+ /**
54
+ * Whether this model takes a forced tool choice — `toolChoice: 'required'` or
55
+ * a named function — under the thinking configuration you intend to send.
56
+ *
57
+ * Built from the same resolution the request path uses, so a caller deciding
58
+ * whether to force a step and the request it then sends cannot disagree.
59
+ * `false` means the driver will refuse that request before sending it; use
60
+ * `toolChoice: 'auto'` and say in the prompt which tool to call.
61
+ */
62
+ export function acceptsForcedToolChoice(model, thinking) {
63
+ const body = resolveThinkingBody(thinking, resolveThinkingCapability(model));
64
+ return forcedToolChoiceRefusal(model, body) === undefined;
65
+ }
66
+ /**
67
+ * Refuse, before transport, a forced tool choice the vendor is certain to reject.
68
+ *
69
+ * The same trade `resolveEffort` makes for an effort level. Sending it costs a
70
+ * round trip to learn what is already known here. Quietly sending `auto`
71
+ * instead would be worse: a forced choice is a contract that the model calls a
72
+ * tool, and a caller relying on it — a step that must produce a structured
73
+ * answer — would get prose back and be told the request succeeded.
74
+ *
75
+ * The error is the `bad_request` `ProviderRequestError` the vendor's 400 would
76
+ * have become, with its own code, so a caller's handling does not change.
77
+ */
78
+ export function assertForcedToolChoiceAccepted(toolChoice, thinkingBody, model) {
79
+ if (!isForced(toolChoice))
80
+ return;
81
+ const refusal = forcedToolChoiceRefusal(model, thinkingBody);
82
+ if (refusal === undefined)
83
+ return;
84
+ throw new ProviderRequestError({
85
+ kind: 'bad_request',
86
+ providerId: 'anthropic',
87
+ providerCode: 'forced_tool_choice_unsupported',
88
+ detail: refusal === 'model'
89
+ ? `Model "${model}" does not accept a forced tool choice (toolChoice "required" or a named function). Use toolChoice "auto" and say in the prompt which tool to call, or responseFormat for a fixed JSON shape.`
90
+ : `A forced tool choice (toolChoice "required" or a named function) cannot be combined with manual extended thinking, which this request's thinking setting resolves to on model "${model}". Use toolChoice "auto", or leave thinking off for this step.`,
91
+ });
92
+ }
93
+ //# sourceMappingURL=tool-choice.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-choice.js","sourceRoot":"","sources":["../src/tool-choice.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA;AAGxE,OAAO,EACN,gBAAgB,EAEhB,mBAAmB,EACnB,yBAAyB,GACzB,MAAM,0BAA0B,CAAA;AACjC,OAAO,EAAqB,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEpE;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,+BAA+B,GAA4B;IAChE,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE;IACtC,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE;IACvC,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE;CACxC,CAAA;AAED,oFAAoF;AACp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CAAC,CAAA;AACH,CAAC"}
@@ -0,0 +1,21 @@
1
+ import type { ModelVersion } from '@namzu/sdk';
2
+ /**
3
+ * A rule that holds for one model family from one version onward.
4
+ *
5
+ * Inclusive and open-ended on purpose. The capability questions this package
6
+ * asks of a model id — can thinking be switched off, will a forced tool choice
7
+ * be taken — have each changed in one direction within a family, and at a
8
+ * MINOR version: `claude-opus-5` can switch thinking off and `claude-opus-5-5`
9
+ * cannot. A list of exact ids needs a row per release and fails open on the
10
+ * next one; a floor needs a row per family per change, and the next release
11
+ * in a family that has crossed inherits the answer instead of falling through
12
+ * to a default that sends a field the wire refuses.
13
+ */
14
+ export interface VersionFloor {
15
+ readonly family: string;
16
+ readonly major: number;
17
+ readonly minor: number;
18
+ }
19
+ /** Whether `version` is at or above the floor listed for its own family. */
20
+ export declare function reachesFloor(version: ModelVersion, floors: readonly VersionFloor[]): boolean;
21
+ //# sourceMappingURL=version-floor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version-floor.d.ts","sourceRoot":"","sources":["../src/version-floor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAE9C;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,YAAY;IAC5B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CACtB;AAED,4EAA4E;AAC5E,wBAAgB,YAAY,CAAC,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,SAAS,YAAY,EAAE,GAAG,OAAO,CAO5F"}
@@ -0,0 +1,7 @@
1
+ /** Whether `version` is at or above the floor listed for its own family. */
2
+ export function reachesFloor(version, floors) {
3
+ return floors.some((floor) => floor.family === version.family &&
4
+ (version.major > floor.major ||
5
+ (version.major === floor.major && version.minor >= floor.minor)));
6
+ }
7
+ //# sourceMappingURL=version-floor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version-floor.js","sourceRoot":"","sources":["../src/version-floor.ts"],"names":[],"mappings":"AAoBA,4EAA4E;AAC5E,MAAM,UAAU,YAAY,CAAC,OAAqB,EAAE,MAA+B;IAClF,OAAO,MAAM,CAAC,IAAI,CACjB,CAAC,KAAK,EAAE,EAAE,CACT,KAAK,CAAC,MAAM,KAAK,OAAO,CAAC,MAAM;QAC/B,CAAC,OAAO,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK;YAC3B,CAAC,OAAO,CAAC,KAAK,KAAK,KAAK,CAAC,KAAK,IAAI,OAAO,CAAC,KAAK,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC,CAClE,CAAA;AACF,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@namzu/anthropic",
3
- "version": "6.1.0",
3
+ "version": "6.2.2",
4
4
  "description": "Anthropic LLM provider for @namzu/sdk via the official @anthropic-ai/sdk. Messages API with streaming, tool-use, and extended thinking support.",
5
5
  "license": "FSL-1.1-MIT",
6
6
  "engines": {
@@ -57,7 +57,7 @@
57
57
  "@types/node": "^22.19.17",
58
58
  "typescript": "^5.5.0",
59
59
  "vitest": "^4.1.11",
60
- "@namzu/sdk": "^44.3.0"
60
+ "@namzu/sdk": "^48.0.0"
61
61
  },
62
62
  "scripts": {
63
63
  "build": "tsc --build",
package/src/client.ts CHANGED
@@ -34,6 +34,7 @@ import {
34
34
  resolveThinkingBody,
35
35
  resolveThinkingCapability,
36
36
  } from './thinking-capability.js'
37
+ import { assertForcedToolChoiceAccepted } from './tool-choice.js'
37
38
  import type { AnthropicConfig } from './types.js'
38
39
 
39
40
  // Floor for `max_tokens` when neither the request nor the provider
@@ -750,6 +751,15 @@ function parseUsage(raw?: RawAnthropicUsage): TokenUsage {
750
751
 
751
752
  type NamzuFinishReason = ChatCompletionResponse['finishReason']
752
753
 
754
+ /**
755
+ * Which limit a `'length'` finish reached, when it was the context window
756
+ * rather than `max_tokens`: after the one the turn loop continues a reply it
757
+ * cut off, and after the other there is no room to continue into.
758
+ */
759
+ function finishDetail(reason?: string | null): Pick<StreamChunk, 'finishDetail'> {
760
+ return reason === 'model_context_window_exceeded' ? { finishDetail: 'context_window' } : {}
761
+ }
762
+
753
763
  function mapStopReason(reason?: string | null): NamzuFinishReason {
754
764
  switch (reason) {
755
765
  case 'end_turn':
@@ -757,8 +767,17 @@ function mapStopReason(reason?: string | null): NamzuFinishReason {
757
767
  return 'stop'
758
768
  case 'tool_use':
759
769
  return 'tool_calls'
770
+ // Both stop the output where it stands. `model_context_window_exceeded`
771
+ // is the context window rather than `max_tokens`, and fell to 'stop':
772
+ // a tool call it cut off mid-JSON then read as one the model finished
773
+ // and got wrong.
760
774
  case 'max_tokens':
775
+ case 'model_context_window_exceeded':
761
776
  return 'length'
777
+ // A refusal can end the response inside a tool_use block. As 'stop' it
778
+ // read as a finished turn, and the unfinished call as malformed.
779
+ case 'refusal':
780
+ return 'content_filter'
762
781
  default:
763
782
  return 'stop'
764
783
  }
@@ -1028,6 +1047,12 @@ export class AnthropicProvider implements LLMProvider {
1028
1047
  const capability = resolveThinkingCapability(model)
1029
1048
  const thinkingBody = resolveThinkingBody(params.thinking, capability)
1030
1049
  if (thinkingBody) body.thinking = thinkingBody
1050
+ // Checked against the thinking body actually going out, and only when
1051
+ // a tool_choice does: some models refuse a forced choice outright, and
1052
+ // manual thinking refuses it on every model that has it.
1053
+ if (body.tool_choice !== undefined) {
1054
+ assertForcedToolChoiceAccepted(params.toolChoice, thinkingBody, model)
1055
+ }
1031
1056
 
1032
1057
  // A sibling of `thinking`, not a field inside it — and gated on the
1033
1058
  // model, since only some accept it at all.
@@ -1355,7 +1380,7 @@ export class AnthropicProvider implements LLMProvider {
1355
1380
  // Without this signal the executor sees an empty
1356
1381
  // `arguments` string and rejects the call with
1357
1382
  // `Error: Invalid JSON in tool arguments for "<tool>"`
1358
- // — exactly the failure the live cowork test
1383
+ // — exactly the failure a live end-to-end run
1359
1384
  // surfaced (Bash + Write both blank-input failed).
1360
1385
  const idx = event.index ?? 0
1361
1386
  if (activeReasoning.delete(idx)) {
@@ -1385,7 +1410,14 @@ export class AnthropicProvider implements LLMProvider {
1385
1410
  if (event.delta.stop_reason === 'pause_turn')
1386
1411
  throw new Error('Anthropic paused hosted search before completing its answer.')
1387
1412
  const search = searchBlocks.complete(providerRoute)
1388
- if (search?.appendix) yield { id: messageId, delta: { content: search.appendix } }
1413
+ // The sources list is the driver's text, not the model's: it
1414
+ // must not read as the model moving on from a tool call the
1415
+ // output limit cut off.
1416
+ if (search?.appendix)
1417
+ yield {
1418
+ id: messageId,
1419
+ delta: { content: search.appendix, contentOrigin: 'driver' },
1420
+ }
1389
1421
  searchReplayEmitted = Boolean(search)
1390
1422
  const replayState = search?.replay ?? completedReplayState()
1391
1423
  yield {
@@ -1393,6 +1425,7 @@ export class AnthropicProvider implements LLMProvider {
1393
1425
  ...(replayState !== undefined ? { replayState } : {}),
1394
1426
  delta: {},
1395
1427
  finishReason: mapStopReason(event.delta.stop_reason),
1428
+ ...finishDetail(event.delta.stop_reason),
1396
1429
  usage: event.usage ? parseUsage(event.usage) : undefined,
1397
1430
  }
1398
1431
  } else if (event.usage) {
@@ -1408,7 +1441,11 @@ export class AnthropicProvider implements LLMProvider {
1408
1441
  if (searchReplayEmitted) return
1409
1442
  const search = searchBlocks.complete(providerRoute)
1410
1443
  if (search) {
1411
- if (search.appendix) yield { id: messageId, delta: { content: search.appendix } }
1444
+ if (search.appendix)
1445
+ yield {
1446
+ id: messageId,
1447
+ delta: { content: search.appendix, contentOrigin: 'driver' },
1448
+ }
1412
1449
  yield { id: messageId, delta: {}, replayState: search.replay }
1413
1450
  return
1414
1451
  }
package/src/index.ts CHANGED
@@ -42,3 +42,9 @@ export type {
42
42
  EffortLevels,
43
43
  ResolvedThinkingBody,
44
44
  } from './thinking-capability.js'
45
+
46
+ // Whether a step may force a tool call on a given model. Some models refuse a
47
+ // forced choice outright, and manual thinking refuses it everywhere; the driver
48
+ // refuses such a request before sending it, and this answers the same question
49
+ // in advance, from the same resolution.
50
+ export { acceptsForcedToolChoice } from './tool-choice.js'
@@ -77,6 +77,27 @@ export function restoreSearch(msg: Assistant, route: ProviderRoute): Block[] | u
77
77
  return structuredClone(state.blocks)
78
78
  }
79
79
 
80
+ /**
81
+ * A block's input for the replay record: what the runtime will record as the
82
+ * call's arguments, which is `{}` when they were empty or could not be read.
83
+ *
84
+ * This parse used to throw. It runs on every `content_block_stop`, client
85
+ * tool calls included, so a tool call the output limit cut off — or one whose
86
+ * JSON the model got wrong — failed the whole stream as "malformed data"
87
+ * before its block-close reached the runtime, and the runtime, seeing a
88
+ * stream error instead of a finish reason, reported every such call as cut
89
+ * off. Reading the arguments is the runtime's job; this record only has to
90
+ * agree with it.
91
+ */
92
+ function replayInput(json: string): unknown {
93
+ if (!json) return {}
94
+ try {
95
+ return JSON.parse(json)
96
+ } catch {
97
+ return {}
98
+ }
99
+ }
100
+
80
101
  /** Accumulate native content separately from locally executable tool calls. */
81
102
  export class SearchBlocks {
82
103
  private readonly blocks = new Map<number, Block>()
@@ -123,7 +144,7 @@ export class SearchBlocks {
123
144
  }
124
145
  stop(index: number) {
125
146
  const b = this.blocks.get(index)
126
- if (b && this.json.has(index)) b.input = JSON.parse(this.json.get(index) ?? '{}')
147
+ if (b && this.json.has(index)) b.input = replayInput(this.json.get(index) ?? '')
127
148
  this.active.delete(index)
128
149
  }
129
150
  complete(route: ProviderRoute) {
@@ -1,6 +1,8 @@
1
1
  import { parseVersionedModelId } from '@namzu/sdk'
2
2
  import type { ModelIdGrammar, ReasoningEffort, ThinkingConfig } from '@namzu/sdk'
3
3
 
4
+ import { type VersionFloor, reachesFloor } from './version-floor.js'
5
+
4
6
  /**
5
7
  * What a given model will actually accept for thinking.
6
8
  *
@@ -15,9 +17,11 @@ import type { ModelIdGrammar, ReasoningEffort, ThinkingConfig } from '@namzu/sdk
15
17
  *
16
18
  * The split, from the vendor's per-model table:
17
19
  *
18
- * - **Adaptive only** — Fable 5, Mythos 5, Opus 5, Sonnet 5, Opus 4.8, Opus
19
- * 4.7. These reject `enabled`. Fable 5 and Mythos 5 additionally reject
20
- * `disabled` because they cannot stop thinking at all.
20
+ * - **Adaptive only** — Fable 5.1, Mythos 5.1, Fable 5, Mythos 5, Opus 5.5,
21
+ * Opus 5, Sonnet 5, Opus 4.8, Opus 4.7. These reject `enabled`. The Fable
22
+ * and Mythos families and Opus from 5.5 additionally reject `disabled`, at
23
+ * every effort level, because they cannot stop thinking at all — see
24
+ * `ALWAYS_ON_FROM`.
21
25
  * - **Both** — Opus 4.6, Sonnet 4.6 (manual mode deprecated but working), and
22
26
  * Mythos Preview (which rejects `disabled`).
23
27
  * - **Manual only** — Opus 4.5, Sonnet 4.5, Haiku 4.5, Opus 4.1. These reject
@@ -60,9 +64,11 @@ export interface ThinkingCapability {
60
64
  /**
61
65
  * The levels still accepted when thinking is switched off.
62
66
  *
63
- * Usually the same set. The Opus 5 family is the exception: it refuses
64
- * `xhigh` and `max` alongside `thinking: {type:"disabled"}` — *"effort 'max'
65
- * is not supported when thinking is disabled"* — while accepting `high`.
67
+ * Usually the same set. Opus 5 is the exception: it refuses `xhigh` and
68
+ * `max` alongside `thinking: {type:"disabled"}` — *"effort 'max' is not
69
+ * supported when thinking is disabled"* — while accepting `high`. On a
70
+ * model that cannot disable thinking this is the full `effort` set, since
71
+ * a `disabled` intent is never sent there.
66
72
  *
67
73
  * This started as a blanket rule applied to every model that can disable
68
74
  * thinking, on the reasoning that the pairing is incoherent anyway. Measured,
@@ -82,6 +88,48 @@ const MANUAL_ONLY: ThinkingCapability = {
82
88
  effortWhenDisabled: NO_EFFORT,
83
89
  }
84
90
 
91
+ /**
92
+ * Thinking is always on: adaptive only, never off, every effort level.
93
+ *
94
+ * `effortWhenDisabled` is the full set because nothing is ever sent disabled
95
+ * here — `resolveThinkingBody` omits that intent on these models — so a
96
+ * caller asking for the levels under a `disabled` intent gets the levels the
97
+ * request will actually carry.
98
+ */
99
+ const ALWAYS_ON: ThinkingCapability = {
100
+ adaptive: true,
101
+ manual: false,
102
+ canDisable: false,
103
+ effort: FULL_EFFORT,
104
+ effortWhenDisabled: FULL_EFFORT,
105
+ }
106
+
107
+ /**
108
+ * Where thinking stops being optional, per family.
109
+ *
110
+ * Data rather than a branch per model. The vendor lists the models that answer
111
+ * `thinking: {type: "disabled"}` with a 400 — Fable 5.1, Mythos 5.1, Fable 5,
112
+ * Mythos 5, Opus 5.5 and Mythos Preview — and the list is two whole families
113
+ * plus Opus from 5.5. Opus crossed at a minor version: `claude-opus-5` takes
114
+ * `disabled` at effort `high` or below, `claude-opus-5-5` refuses it at every
115
+ * level.
116
+ *
117
+ * That crossing is why this is a table. The version fallback below reads every
118
+ * newer id in an adaptive family as able to switch thinking off, so the first
119
+ * always-on Opus resolved to `canDisable: true` and a shared `disabled` intent
120
+ * went out verbatim and came back 400 — on a config that worked on the model
121
+ * one minor below. The next family to cross is one row here, and a later
122
+ * version of a family that has crossed is covered without one.
123
+ *
124
+ * Mythos Preview is not a row: it carries no version to compare, and it keeps
125
+ * manual mode, so `resolveThinkingCapability` resolves it by name.
126
+ */
127
+ const ALWAYS_ON_FROM: readonly VersionFloor[] = [
128
+ { family: 'fable', major: 0, minor: 0 },
129
+ { family: 'mythos', major: 0, minor: 0 },
130
+ { family: 'opus', major: 5, minor: 5 },
131
+ ]
132
+
85
133
  /**
86
134
  * The vocabulary this driver's ids are spelled in.
87
135
  *
@@ -142,25 +190,20 @@ export function resolveThinkingCapability(model: string): ThinkingCapability {
142
190
 
143
191
  const { family, major, minor } = parsed
144
192
 
145
- // Always-on families: thinking cannot be disabled at any version.
146
- if (family === 'fable' || family === 'mythos') {
147
- return {
148
- adaptive: true,
149
- manual: false,
150
- canDisable: false,
151
- effort: FULL_EFFORT,
152
- effortWhenDisabled: FULL_EFFORT,
153
- }
154
- }
193
+ // Thinking cannot be disabled from here on, whatever the effort level.
194
+ // Checked before the version fallback, which would otherwise read the id
195
+ // as a newer adaptive model that can switch thinking off.
196
+ if (reachesFloor(parsed, ALWAYS_ON_FROM)) return ALWAYS_ON
155
197
 
156
198
  // 4.7 and later dropped manual mode outright.
157
199
  if (major > 4 || (major === 4 && minor >= 7)) {
158
- // The Opus 5 family alone caps effort while thinking is off. Measured,
159
- // not inferred: `claude-opus-5` refuses `disabled` + `xhigh`/`max` and
200
+ // Opus 5 alone caps effort while thinking is off. Measured, not
201
+ // inferred: `claude-opus-5` refuses `disabled` + `xhigh`/`max` and
160
202
  // accepts `disabled` + `high`, while `claude-sonnet-5` and
161
203
  // `claude-opus-4-8` accept `disabled` + `max`. A version comparison of
162
204
  // "5 and later" would have caught Sonnet 5 too and dropped an effort
163
- // that wire honours.
205
+ // that wire honours. Opus from 5.5 never reaches this line: it cannot
206
+ // switch thinking off at all, and returned above.
164
207
  const opus5Plus = family === 'opus' && major >= 5
165
208
  return {
166
209
  adaptive: true,