maestro-agent-sdk 0.1.19 → 0.1.21

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.
@@ -36,6 +36,39 @@ export declare class AnthropicProvider implements Provider {
36
36
  */
37
37
  stream(opts: ProviderCompleteOptions): AsyncGenerator<ProviderStreamChunk>;
38
38
  }
39
+ /**
40
+ * Defensive scrub for thinking blocks that arrive at the wire builder without
41
+ * a usable `signature`. Anthropic's API requires every replayed `thinking`
42
+ * block to carry the original signature it produced; sending one without it
43
+ * trips a 400 `messages.N.content.M.thinking.signature: Field required`.
44
+ *
45
+ * In normal operation the streaming code already refuses to emit
46
+ * thinking blocks lacking a signature (see `content_block_stop` in the SSE
47
+ * handler), so this filter is belt-and-suspenders for two recovery cases:
48
+ *
49
+ * 1. A session persisted by an older SDK build (pre-v0.1.20) that DID
50
+ * emit signatureless thinking blocks now loads from disk. Without this
51
+ * filter, the first wire call after upgrading would 400 on the bad
52
+ * block.
53
+ *
54
+ * 2. A future provider-side transformation (compaction, dedup) accidentally
55
+ * drops the field. Filtering here gives us a single chokepoint to lock.
56
+ *
57
+ * Two complications the filter has to handle:
58
+ *
59
+ * - **Anthropic forbids mixing `thinking` and `text` after `tool_use` /
60
+ * `tool_result` in the same message.** Simply removing the bad thinking
61
+ * block can leave a message starting with `text` + `tool_use`, which is
62
+ * still valid. So we only drop the thinking block itself, not surrounding
63
+ * blocks.
64
+ *
65
+ * - **An assistant message can become content-empty after the filter.** A
66
+ * turn like `[thinking(broken)]` reduces to `[]`. Anthropic rejects empty
67
+ * content arrays, so we substitute a single empty text block as a
68
+ * placeholder — same trick `loop.ts` already uses for the scrubber-drops-
69
+ * everything case.
70
+ */
71
+ export declare function sanitizeThinkingBlocksForWire(messages: readonly ProviderMessage[]): ProviderMessage[];
39
72
  /**
40
73
  * Convert the user-supplied `system` (plain string) into the array shape
41
74
  * Anthropic accepts when you need a cache_control marker. A string slot
@@ -101,31 +134,84 @@ export declare function applyThinkingBudget(body: Record<string, unknown>, budge
101
134
  * `MAESTRO_EFFORT_VALUES`); other values return undefined so the caller skips
102
135
  * thinking entirely.
103
136
  *
104
- * Scale (v0.1.16):
105
- * - low → 2 048
106
- * - medium → 8 192
107
- * - high → 16 384
108
- * - xhigh → 16 384 (same ceiling as `high` — the difference is persona,
109
- * not budget. `xhigh` tells the model to use the same
110
- * thinking allowance more broadly: hold multiple
111
- * hypotheses, survey, name edge cases. The ceiling
112
- * is shared because empirically thinking ROI above
113
- * ~16K drops sharply on sonnet-4-6 / haiku-4-5;
114
- * bumping the budget didn't change answer quality
115
- * as much as bumping the persona's instructions.)
116
- * - max → 32 768 (halved from v0.1.15's 65 536. 64K thinking is
117
- * almost never fully utilized in a single turn;
118
- * the latency penalty was unrecouped. 32K is the
119
- * ceiling for "really chew on this" without paying
120
- * for theoretical headroom the model doesn't reach.)
137
+ * Scale (v0.1.19+ — aligned with the prompt-keyword tier ladder):
138
+ * - low → undefined (thinking off — latency-priority working mode)
139
+ * - medium → undefined (thinking off — default; matches Claude Code's
140
+ * "off unless asked" behavior. Persona text still
141
+ * shapes the model's working style, but the API
142
+ * ships without a `thinking` payload.)
143
+ * - high → 4 096 (T1 same as the `think` / `생각해줘` keyword)
144
+ * - xhigh → 10 000 (T2 same as `think hard` / `깊이 생각`)
145
+ * - max → 31 999 (T3 same as `ultrathink` / `끝까지 생각`)
146
+ *
147
+ * Why only high/xhigh/max grant thinking: the lower three rungs are the
148
+ * conversational defaults where fast tool dispatch beats deeper reasoning
149
+ * (Telegram bot, chat UI, simple file ops). Users who want extended
150
+ * thinking either escalate via the effort knob explicitly or type the
151
+ * keyword in the prompt both routes land on the same three tier budgets,
152
+ * so behavior is predictable across surfaces.
153
+ *
154
+ * Symmetry with `detectThinkingKeyword`: the three "on" tiers here mirror
155
+ * the three keyword tiers exactly. Whichever path activates thinking, the
156
+ * model sees one of {4096, 10000, 31999} — no fourth budget exists.
157
+ * `resolveThinkingBudget` (provider.ts) picks the higher of the two if
158
+ * both fire, so an `effort: "high"` call that happens to contain
159
+ * "ultrathink" in the prompt still gets T3, not T1.
121
160
  *
122
161
  * Budgets are *ceilings*, not enforced spending: the model decides how
123
- * much to actually emit inside the budget. So a 32K ceiling on a simple
124
- * task still costs almost nothing — the savings come from latency, not
125
- * tokens, since the model returns sooner when it knows the budget is
126
- * smaller.
162
+ * much to actually emit inside the budget. A 31999 ceiling on a simple
163
+ * task still costs almost nothing — the savings come from latency
164
+ * (model returns sooner when it knows the budget is smaller).
127
165
  */
128
166
  export declare function effortToThinkingBudget(e: string | undefined): number | undefined;
167
+ /**
168
+ * Claude Code-style think-keyword detection.
169
+ *
170
+ * Scans the caller's user prompt for an explicit "think harder" cue. When
171
+ * present, returns the matching thinking-budget tier; otherwise returns
172
+ * undefined (the loop then ships the call with thinking disabled — same
173
+ * default Claude Code uses).
174
+ *
175
+ * Why this exists alongside `effortToThinkingBudget`:
176
+ * - `effort` is a *programmatic* knob set by the SDK consumer (CLI flag,
177
+ * config file, server-side default). It's awkward to plumb through
178
+ * conversational surfaces like a Telegram bot or chat UI where the user
179
+ * just types text.
180
+ * - The keyword path lets end-users toggle thinking via the prompt itself
181
+ * ("think harder", "끝까지 생각해줘") without the host having to wire
182
+ * UI for an effort selector. This matches Claude Code's behavior and
183
+ * is what users coming from CC instinctively try.
184
+ *
185
+ * Tier mapping mirrors Claude Code's documented set:
186
+ * tier 3 (max) → 31999 tokens — "ultrathink", "think harder",
187
+ * "끝까지 생각", "심층 생각"
188
+ * tier 2 (deep) → 10000 tokens — "think hard", "think a lot",
189
+ * "깊이 생각", "깊게 생각"
190
+ * tier 1 (basic) → 4096 tokens — "think" (English), "생각해줘" /
191
+ * "생각해봐" / "잘 생각" (Korean)
192
+ *
193
+ * Why 31999 (not 32768): Anthropic requires `max_tokens > budget`, and
194
+ * 31999 + 1024 = 33023 stays under the 64K max_tokens ceiling on sonnet-4-6
195
+ * while leaving room for the final text response. Picking 32768 would force
196
+ * max_tokens to ≥ 33792 which loses headroom for long answers.
197
+ *
198
+ * Why "think" word-boundary on English but substring on Korean:
199
+ * English splits with whitespace so `\bthink\b` cleanly avoids false hits
200
+ * on "thinking" / "rethink". Korean morphology glues particles to verbs
201
+ * ("생각해줘" / "생각해봐"), so we substring-match the verb stem and accept
202
+ * the false-positive rate (a Korean user saying "그는 잘 생각해" in a code
203
+ * snippet would unintentionally trigger — same trade-off CC made in
204
+ * English).
205
+ *
206
+ * Highest tier wins: if both "think" and "ultrathink" appear (e.g. "think
207
+ * about this — actually ultrathink"), we honor the higher budget. Tier
208
+ * ordering matters because tier-3 substrings contain tier-1's pattern.
209
+ *
210
+ * Pure helper — no side effects, safe to call on every turn. Exposed for
211
+ * tests and for hosts that want to compose their own keyword surfaces
212
+ * (e.g. add Japanese keywords without forking).
213
+ */
214
+ export declare function detectThinkingKeyword(prompt: string | undefined): number | undefined;
129
215
  /**
130
216
  * Resolve the actual thinking budget the loop should send on *this turn*,
131
217
  * given the base budget (already derived from effort) and the turn's
@@ -1 +1 @@
1
- {"version":3,"file":"anthropic.d.ts","sourceRoot":"","sources":["../../src/providers/anthropic.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,QAAQ,EACR,uBAAuB,EAEvB,eAAe,EACf,gBAAgB,EAChB,mBAAmB,EACnB,kBAAkB,EACnB,MAAM,kBAAkB,CAAC;AAO1B;oEACoE;AACpE,KAAK,YAAY,GAAG;IAAE,IAAI,EAAE,WAAW,CAAA;CAAE,CAAC;AAwB1C;;;;;;;;;;;GAWG;AACH,qBAAa,iBAAkB,YAAW,QAAQ;IACpC,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,MAAM;IAE3C,MAAM,CAAC,OAAO,IAAI,iBAAiB;IAQ7B,QAAQ,CAAC,IAAI,EAAE,uBAAuB,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAqDxE;;;;;;;;;;;;OAYG;IACI,MAAM,CAAC,IAAI,EAAE,uBAAuB,GAAG,cAAc,C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AgBG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,SAAS,eAAe,EAAE,GAAG,eAAe,EAAE,CA6B9F;AAGD,eAAO,MAAM,oBAAoB,IAAwB,CAAC;AAE1D;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,MAAM,EAAE,MAAM,GAAG,SAAS,GACzB,IAAI,CAMN;AAOD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAehF;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CA2CpF;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,MAAM,GAAG,SAAS,EACxB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,GACd,MAAM,GAAG,SAAS,CAcpB;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAInE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,wBAAgB,qBAAqB,CAAC,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAqD/E"}
@@ -46,7 +46,7 @@ export class AnthropicProvider {
46
46
  model: opts.model,
47
47
  max_tokens: opts.maxTokens ?? 4096,
48
48
  system: buildCacheableSystem(opts.system),
49
- messages: buildCacheableMessages(opts.messages),
49
+ messages: buildCacheableMessages(sanitizeThinkingBlocksForWire(opts.messages)),
50
50
  };
51
51
  if (opts.tools && opts.tools.length > 0) {
52
52
  body.tools = buildCacheableTools(opts.tools);
@@ -96,7 +96,7 @@ export class AnthropicProvider {
96
96
  model: opts.model,
97
97
  max_tokens: opts.maxTokens ?? 4096,
98
98
  system: buildCacheableSystem(opts.system),
99
- messages: buildCacheableMessages(opts.messages),
99
+ messages: buildCacheableMessages(sanitizeThinkingBlocksForWire(opts.messages)),
100
100
  stream: true,
101
101
  };
102
102
  if (opts.tools && opts.tools.length > 0) {
@@ -221,14 +221,34 @@ export class AnthropicProvider {
221
221
  };
222
222
  }
223
223
  else if (meta?.type === "thinking") {
224
- yield {
225
- type: "thinking_complete",
226
- block: {
227
- type: "thinking",
228
- thinking: meta.thinking ?? "",
229
- ...(meta.signature ? { signature: meta.signature } : {}),
230
- },
231
- };
224
+ // CRITICAL: drop the block entirely when no signature was
225
+ // collected. Anthropic requires a `signature` field on every
226
+ // replayed `thinking` block — sending one without it 400s the
227
+ // next API call with
228
+ // "messages.N.content.M.thinking.signature: Field required".
229
+ //
230
+ // Two paths lead here:
231
+ // 1. No `signature_delta` ever arrived (server-side hiccup,
232
+ // mid-block stream interrupt — rare but observed).
233
+ // 2. `signature_delta` arrived with an empty string. The
234
+ // concat `${meta.signature ?? ""}${delta.signature}` then
235
+ // yielded "", which we treat the same as missing.
236
+ //
237
+ // An empty signature isn't a valid signature (Anthropic's
238
+ // verification would reject it anyway), so it's safer to drop
239
+ // the block from history. The model loses some reasoning
240
+ // continuity for this turn, but the conversation continues —
241
+ // strictly better than the alternative (whole turn fails).
242
+ if (typeof meta.signature === "string" && meta.signature.length > 0) {
243
+ yield {
244
+ type: "thinking_complete",
245
+ block: {
246
+ type: "thinking",
247
+ thinking: meta.thinking ?? "",
248
+ signature: meta.signature,
249
+ },
250
+ };
251
+ }
232
252
  }
233
253
  else if (meta?.type === "redacted_thinking") {
234
254
  yield {
@@ -329,6 +349,65 @@ async function* parseSseStream(body, abortSignal) {
329
349
  reader.releaseLock();
330
350
  }
331
351
  }
352
+ /**
353
+ * Defensive scrub for thinking blocks that arrive at the wire builder without
354
+ * a usable `signature`. Anthropic's API requires every replayed `thinking`
355
+ * block to carry the original signature it produced; sending one without it
356
+ * trips a 400 `messages.N.content.M.thinking.signature: Field required`.
357
+ *
358
+ * In normal operation the streaming code already refuses to emit
359
+ * thinking blocks lacking a signature (see `content_block_stop` in the SSE
360
+ * handler), so this filter is belt-and-suspenders for two recovery cases:
361
+ *
362
+ * 1. A session persisted by an older SDK build (pre-v0.1.20) that DID
363
+ * emit signatureless thinking blocks now loads from disk. Without this
364
+ * filter, the first wire call after upgrading would 400 on the bad
365
+ * block.
366
+ *
367
+ * 2. A future provider-side transformation (compaction, dedup) accidentally
368
+ * drops the field. Filtering here gives us a single chokepoint to lock.
369
+ *
370
+ * Two complications the filter has to handle:
371
+ *
372
+ * - **Anthropic forbids mixing `thinking` and `text` after `tool_use` /
373
+ * `tool_result` in the same message.** Simply removing the bad thinking
374
+ * block can leave a message starting with `text` + `tool_use`, which is
375
+ * still valid. So we only drop the thinking block itself, not surrounding
376
+ * blocks.
377
+ *
378
+ * - **An assistant message can become content-empty after the filter.** A
379
+ * turn like `[thinking(broken)]` reduces to `[]`. Anthropic rejects empty
380
+ * content arrays, so we substitute a single empty text block as a
381
+ * placeholder — same trick `loop.ts` already uses for the scrubber-drops-
382
+ * everything case.
383
+ */
384
+ export function sanitizeThinkingBlocksForWire(messages) {
385
+ let mutated = false;
386
+ const out = messages.map((msg) => {
387
+ if (!Array.isArray(msg.content))
388
+ return msg;
389
+ let blockChanged = false;
390
+ const filtered = msg.content.filter((block) => {
391
+ if (block.type !== "thinking")
392
+ return true;
393
+ const sig = block.signature;
394
+ const valid = typeof sig === "string" && sig.length > 0;
395
+ if (!valid) {
396
+ blockChanged = true;
397
+ return false;
398
+ }
399
+ return true;
400
+ });
401
+ if (!blockChanged)
402
+ return msg;
403
+ mutated = true;
404
+ // Empty content array isn't a valid Anthropic message — keep one
405
+ // placeholder text block so the turn stays well-formed.
406
+ const safe = filtered.length > 0 ? filtered : [{ type: "text", text: "" }];
407
+ return { role: msg.role, content: safe };
408
+ });
409
+ return mutated ? out : messages;
410
+ }
332
411
  /**
333
412
  * Convert the user-supplied `system` (plain string) into the array shape
334
413
  * Anthropic accepts when you need a cache_control marker. A string slot
@@ -445,46 +524,133 @@ function applyThinkingHeaders(headers, budget) {
445
524
  * `MAESTRO_EFFORT_VALUES`); other values return undefined so the caller skips
446
525
  * thinking entirely.
447
526
  *
448
- * Scale (v0.1.16):
449
- * - low → 2 048
450
- * - medium → 8 192
451
- * - high → 16 384
452
- * - xhigh → 16 384 (same ceiling as `high` — the difference is persona,
453
- * not budget. `xhigh` tells the model to use the same
454
- * thinking allowance more broadly: hold multiple
455
- * hypotheses, survey, name edge cases. The ceiling
456
- * is shared because empirically thinking ROI above
457
- * ~16K drops sharply on sonnet-4-6 / haiku-4-5;
458
- * bumping the budget didn't change answer quality
459
- * as much as bumping the persona's instructions.)
460
- * - max → 32 768 (halved from v0.1.15's 65 536. 64K thinking is
461
- * almost never fully utilized in a single turn;
462
- * the latency penalty was unrecouped. 32K is the
463
- * ceiling for "really chew on this" without paying
464
- * for theoretical headroom the model doesn't reach.)
527
+ * Scale (v0.1.19+ — aligned with the prompt-keyword tier ladder):
528
+ * - low → undefined (thinking off — latency-priority working mode)
529
+ * - medium → undefined (thinking off — default; matches Claude Code's
530
+ * "off unless asked" behavior. Persona text still
531
+ * shapes the model's working style, but the API
532
+ * ships without a `thinking` payload.)
533
+ * - high → 4 096 (T1 same as the `think` / `생각해줘` keyword)
534
+ * - xhigh → 10 000 (T2 same as `think hard` / `깊이 생각`)
535
+ * - max → 31 999 (T3 same as `ultrathink` / `끝까지 생각`)
536
+ *
537
+ * Why only high/xhigh/max grant thinking: the lower three rungs are the
538
+ * conversational defaults where fast tool dispatch beats deeper reasoning
539
+ * (Telegram bot, chat UI, simple file ops). Users who want extended
540
+ * thinking either escalate via the effort knob explicitly or type the
541
+ * keyword in the prompt both routes land on the same three tier budgets,
542
+ * so behavior is predictable across surfaces.
543
+ *
544
+ * Symmetry with `detectThinkingKeyword`: the three "on" tiers here mirror
545
+ * the three keyword tiers exactly. Whichever path activates thinking, the
546
+ * model sees one of {4096, 10000, 31999} — no fourth budget exists.
547
+ * `resolveThinkingBudget` (provider.ts) picks the higher of the two if
548
+ * both fire, so an `effort: "high"` call that happens to contain
549
+ * "ultrathink" in the prompt still gets T3, not T1.
465
550
  *
466
551
  * Budgets are *ceilings*, not enforced spending: the model decides how
467
- * much to actually emit inside the budget. So a 32K ceiling on a simple
468
- * task still costs almost nothing — the savings come from latency, not
469
- * tokens, since the model returns sooner when it knows the budget is
470
- * smaller.
552
+ * much to actually emit inside the budget. A 31999 ceiling on a simple
553
+ * task still costs almost nothing — the savings come from latency
554
+ * (model returns sooner when it knows the budget is smaller).
471
555
  */
472
556
  export function effortToThinkingBudget(e) {
473
557
  switch (e) {
474
558
  case "low":
475
- return 2048;
559
+ return undefined;
476
560
  case "medium":
477
- return 8192;
561
+ return undefined;
478
562
  case "high":
479
- return 16384;
563
+ return 4096;
480
564
  case "xhigh":
481
- return 16384;
565
+ return 10000;
482
566
  case "max":
483
- return 32768;
567
+ return 31999;
484
568
  default:
485
569
  return undefined;
486
570
  }
487
571
  }
572
+ /**
573
+ * Claude Code-style think-keyword detection.
574
+ *
575
+ * Scans the caller's user prompt for an explicit "think harder" cue. When
576
+ * present, returns the matching thinking-budget tier; otherwise returns
577
+ * undefined (the loop then ships the call with thinking disabled — same
578
+ * default Claude Code uses).
579
+ *
580
+ * Why this exists alongside `effortToThinkingBudget`:
581
+ * - `effort` is a *programmatic* knob set by the SDK consumer (CLI flag,
582
+ * config file, server-side default). It's awkward to plumb through
583
+ * conversational surfaces like a Telegram bot or chat UI where the user
584
+ * just types text.
585
+ * - The keyword path lets end-users toggle thinking via the prompt itself
586
+ * ("think harder", "끝까지 생각해줘") without the host having to wire
587
+ * UI for an effort selector. This matches Claude Code's behavior and
588
+ * is what users coming from CC instinctively try.
589
+ *
590
+ * Tier mapping mirrors Claude Code's documented set:
591
+ * tier 3 (max) → 31999 tokens — "ultrathink", "think harder",
592
+ * "끝까지 생각", "심층 생각"
593
+ * tier 2 (deep) → 10000 tokens — "think hard", "think a lot",
594
+ * "깊이 생각", "깊게 생각"
595
+ * tier 1 (basic) → 4096 tokens — "think" (English), "생각해줘" /
596
+ * "생각해봐" / "잘 생각" (Korean)
597
+ *
598
+ * Why 31999 (not 32768): Anthropic requires `max_tokens > budget`, and
599
+ * 31999 + 1024 = 33023 stays under the 64K max_tokens ceiling on sonnet-4-6
600
+ * while leaving room for the final text response. Picking 32768 would force
601
+ * max_tokens to ≥ 33792 which loses headroom for long answers.
602
+ *
603
+ * Why "think" word-boundary on English but substring on Korean:
604
+ * English splits with whitespace so `\bthink\b` cleanly avoids false hits
605
+ * on "thinking" / "rethink". Korean morphology glues particles to verbs
606
+ * ("생각해줘" / "생각해봐"), so we substring-match the verb stem and accept
607
+ * the false-positive rate (a Korean user saying "그는 잘 생각해" in a code
608
+ * snippet would unintentionally trigger — same trade-off CC made in
609
+ * English).
610
+ *
611
+ * Highest tier wins: if both "think" and "ultrathink" appear (e.g. "think
612
+ * about this — actually ultrathink"), we honor the higher budget. Tier
613
+ * ordering matters because tier-3 substrings contain tier-1's pattern.
614
+ *
615
+ * Pure helper — no side effects, safe to call on every turn. Exposed for
616
+ * tests and for hosts that want to compose their own keyword surfaces
617
+ * (e.g. add Japanese keywords without forking).
618
+ */
619
+ export function detectThinkingKeyword(prompt) {
620
+ if (!prompt)
621
+ return undefined;
622
+ const lower = prompt.toLowerCase();
623
+ // Tier 3 — max. Order matters: check the highest tier first so a prompt
624
+ // containing "ultrathink" doesn't get downgraded by an earlier "think"
625
+ // match. Korean cues sit alongside the English set; substring match is
626
+ // intentional (see docstring).
627
+ if (/\bultrathink\b/.test(lower) ||
628
+ /\bthink\s+harder\b/.test(lower) ||
629
+ /\bmegathink\b/.test(lower) ||
630
+ prompt.includes("끝까지 생각") ||
631
+ prompt.includes("심층 생각")) {
632
+ return 31999;
633
+ }
634
+ // Tier 2 — deep.
635
+ if (/\bthink\s+hard\b/.test(lower) ||
636
+ /\bthink\s+a\s+lot\b/.test(lower) ||
637
+ prompt.includes("깊이 생각") ||
638
+ prompt.includes("깊게 생각")) {
639
+ return 10000;
640
+ }
641
+ // Tier 1 — basic. The English `\bthink\b` is broad and will fire on any
642
+ // standalone "think" mention; that's the documented Claude Code behavior
643
+ // and matches user intuition. For Korean we require an imperative-ish
644
+ // form ("생각해줘" / "생각해봐") or a deliberate modifier ("잘 생각") to
645
+ // avoid casual triggering on words like "생각" in a description.
646
+ if (/\bthink\b/.test(lower) ||
647
+ prompt.includes("생각해줘") ||
648
+ prompt.includes("생각해봐") ||
649
+ prompt.includes("잘 생각")) {
650
+ return 4096;
651
+ }
652
+ return undefined;
653
+ }
488
654
  /**
489
655
  * Resolve the actual thinking budget the loop should send on *this turn*,
490
656
  * given the base budget (already derived from effort) and the turn's
@@ -1 +1 @@
1
- {"version":3,"file":"anthropic.js","sourceRoot":"","sources":["../../src/providers/anthropic.ts"],"names":[],"mappings":"AAWA,MAAM,iBAAiB,GAAG,uCAAuC,CAAC;AAClE,MAAM,iBAAiB,GAAG,YAAY,CAAC;AACvC,MAAM,yBAAyB,GAAG,iCAAiC,CAAC;AAMpE;;0DAE0D;AAC1D,MAAM,qBAAqB,GAAG,CAAC,CAAC;AAmBhC;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,iBAAiB;IACC;IAA7B,YAA6B,MAAc;QAAd,WAAM,GAAN,MAAM,CAAQ;IAAG,CAAC;IAE/C,MAAM,CAAC,OAAO;QACZ,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC;QAC7C,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,IAAI,KAAK,CAAC,iEAAiE,CAAC,CAAC;QACrF,CAAC;QACD,OAAO,IAAI,iBAAiB,CAAC,MAAM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,GAAe;QACtB,WAAW,EAAE,CAAC,CAAC,YAAY;QAC3B,YAAY,EAAE,CAAC,CAAC,aAAa;KAC9B,CAAC;IACF,IAAI,CAAC,CAAC,2BAA2B,KAAK,SAAS,EAAE,CAAC;QAChD,GAAG,CAAC,wBAAwB,GAAG,CAAC,CAAC,2BAA2B,CAAC;IAC/D,CAAC;IACD,IAAI,CAAC,CAAC,uBAAuB,KAAK,SAAS,EAAE,CAAC;QAC5C,GAAG,CAAC,oBAAoB,GAAG,CAAC,CAAC,uBAAuB,CAAC;IACvD,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -1,3 +1,69 @@
1
1
  import type { AgentRegistry } from "./agents/contracts.js";
2
+ /**
3
+ * Per-model default `max_tokens` ceiling — the value the SDK ships to the
4
+ * provider when the caller doesn't pin `AgentQueryOptions.maxTokens` itself.
5
+ *
6
+ * v0.1.21+ replaces the previous flat 4096 fallback (which silently truncated
7
+ * any output > 4K — see the v0.1.20 ↔ v0.1.21 changelog for the bug it caused
8
+ * in long-form report generation). The new defaults are picked per-model
9
+ * rather than blanket because the providers diverge sharply:
10
+ *
11
+ * - **Claude** (Anthropic) caps native output at 64K (sonnet/haiku) or 128K
12
+ * (opus 4.7). These are realistic ceilings for actual long-form work, so
13
+ * the default IS the native cap — matches `@anthropic-ai/claude-agent-sdk`
14
+ * behavior where caller omitting `maxTokens` gets the per-model native
15
+ * max from the SDK's model catalog.
16
+ *
17
+ * - **DeepSeek V4** caps native output at 384K (both pro and flash). That's
18
+ * ~290k English words in one shot — far beyond any practical single-turn
19
+ * use case. Defaulting to native here would mean a single runaway turn
20
+ * could rack up serious cost and 30-minute+ wall time before the loop
21
+ * even notices. We pin a smaller default per variant:
22
+ * - `deepseek-v4-pro` → 65_536 (matches the Claude Sonnet / Haiku
23
+ * 64K reference point so a topic
24
+ * switching providers sees the same
25
+ * default ceiling)
26
+ * - `deepseek-v4-flash` → 32_768 (latency-tier — flash users prefer
27
+ * snappier responses; long outputs
28
+ * should escalate to pro)
29
+ * Callers that genuinely need the full 384K still get it via the
30
+ * `AgentQueryOptions.maxTokens` override — the catalog is a default,
31
+ * not a hard ceiling.
32
+ *
33
+ * - **Unknown model ids** fall back to `DEFAULT_MAX_OUTPUT_TOKENS` (32_768)
34
+ * via `getNativeMaxOutputTokens`. The fallback is sized to "comfortably
35
+ * covers most long-form outputs" — picking 4096 like v0.1.20 reintroduces
36
+ * the original silent-truncation bug for any new model the caller hasn't
37
+ * registered yet, so we err on the generous side. Callers running an
38
+ * unknown model who want to clamp output should set `maxTokens` explicitly.
39
+ *
40
+ * The catalog is read at exactly one site — `AIAgent`'s constructor in
41
+ * `src/core/agent.ts` — via the `getNativeMaxOutputTokens(model)` helper.
42
+ * Adding a new model: extend this table and the corresponding alias entry.
43
+ */
44
+ export declare const MODEL_MAX_OUTPUT_TOKENS: Readonly<Record<string, number>>;
45
+ /**
46
+ * Default `max_tokens` for an unknown model id. Sized generously (32_768)
47
+ * because the previous 4096 fallback silently truncated long outputs on every
48
+ * known model — picking that low again for unknowns would re-introduce the
49
+ * same class of bug for any model the catalog hasn't been updated for yet.
50
+ *
51
+ * Hosts that want to clamp an unknown model can pass `maxTokens` explicitly
52
+ * on `AgentQueryOptions`; the catalog is a default, not a hard ceiling.
53
+ */
54
+ export declare const DEFAULT_MAX_OUTPUT_TOKENS: 32768;
55
+ /**
56
+ * Resolve the per-API-call `max_tokens` default for a given resolved model id.
57
+ *
58
+ * Returns the catalog entry when the model is registered, or
59
+ * `DEFAULT_MAX_OUTPUT_TOKENS` (32_768) otherwise. Pure helper — no side
60
+ * effects, safe to call on every loop iteration.
61
+ *
62
+ * Used by `AIAgent` to compute its `maxTokens` default when the caller
63
+ * doesn't pin one via `AgentQueryOptions.maxTokens`. Exposed so hosts can
64
+ * surface the same number in their UI (e.g. "this run will cap at 64K
65
+ * output tokens") without duplicating the table.
66
+ */
67
+ export declare function getNativeMaxOutputTokens(model: string): number;
2
68
  export declare const maestroRegistry: AgentRegistry;
3
69
  //# sourceMappingURL=registry.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAkCxD,eAAO,MAAM,eAAe,EAAE,aAkF7B,CAAC"}
1
+ {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAuCxD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,eAAO,MAAM,uBAAuB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAQ3D,CAAC;AAEX;;;;;;;;GAQG;AACH,eAAO,MAAM,yBAAyB,EAAG,KAAe,CAAC;AAEzD;;;;;;;;;;;GAWG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE9D;AAED,eAAO,MAAM,eAAe,EAAE,aAkF7B,CAAC"}