@truefoundry/ai-gateway-sdk 0.1.15 → 0.1.16

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 (132) hide show
  1. package/dist/adapters/messages/index.js +2 -2
  2. package/dist/adapters/messages/index.js.map +1 -1
  3. package/dist/adapters/responses/requestTransform.js +49 -9
  4. package/dist/adapters/responses/requestTransform.js.map +1 -1
  5. package/dist/adapters/responses/responseTransform.js +24 -19
  6. package/dist/adapters/responses/responseTransform.js.map +1 -1
  7. package/dist/adapters/responses/streamTransform.d.ts +2 -0
  8. package/dist/adapters/responses/streamTransform.js +63 -35
  9. package/dist/adapters/responses/streamTransform.js.map +1 -1
  10. package/dist/globals.d.ts +46 -0
  11. package/dist/globals.js +85 -0
  12. package/dist/globals.js.map +1 -1
  13. package/dist/providers/anthropic/anthropicBetas.d.ts +10 -0
  14. package/dist/providers/anthropic/anthropicBetas.js +19 -0
  15. package/dist/providers/anthropic/anthropicBetas.js.map +1 -1
  16. package/dist/providers/anthropic/betaTracing.js +1 -0
  17. package/dist/providers/anthropic/betaTracing.js.map +1 -1
  18. package/dist/providers/anthropic/chatComplete.d.ts +29 -0
  19. package/dist/providers/anthropic/chatComplete.js +70 -35
  20. package/dist/providers/anthropic/chatComplete.js.map +1 -1
  21. package/dist/providers/anthropic/droppedBetaNote.d.ts +7 -0
  22. package/dist/providers/anthropic/droppedBetaNote.js +32 -0
  23. package/dist/providers/anthropic/droppedBetaNote.js.map +1 -0
  24. package/dist/providers/anthropic/serverTools.d.ts +6 -0
  25. package/dist/providers/anthropic/serverTools.js +19 -0
  26. package/dist/providers/anthropic/serverTools.js.map +1 -1
  27. package/dist/providers/anthropic/utils.d.ts +17 -0
  28. package/dist/providers/anthropic/utils.js +19 -0
  29. package/dist/providers/anthropic/utils.js.map +1 -1
  30. package/dist/providers/anthropic-base/messages.js +2 -0
  31. package/dist/providers/anthropic-base/messages.js.map +1 -1
  32. package/dist/providers/anthropic-base/thinking.d.ts +12 -0
  33. package/dist/providers/anthropic-base/thinking.js +19 -0
  34. package/dist/providers/anthropic-base/thinking.js.map +1 -0
  35. package/dist/providers/anthropic-base/types.d.ts +4 -0
  36. package/dist/providers/aws-bedrock-mantle/index.d.ts +5 -3
  37. package/dist/providers/aws-bedrock-mantle/index.js +9 -2
  38. package/dist/providers/aws-bedrock-mantle/index.js.map +1 -1
  39. package/dist/providers/azure-openai/index.d.ts +1 -1
  40. package/dist/providers/bedrock/chatComplete.d.ts +4 -0
  41. package/dist/providers/bedrock/chatComplete.js +64 -17
  42. package/dist/providers/bedrock/chatComplete.js.map +1 -1
  43. package/dist/providers/bedrock/index.d.ts +1 -1
  44. package/dist/providers/bedrock/index.js +9 -2
  45. package/dist/providers/bedrock/index.js.map +1 -1
  46. package/dist/providers/bedrock/messages.js +2 -1
  47. package/dist/providers/bedrock/messages.js.map +1 -1
  48. package/dist/providers/bedrock/types.d.ts +18 -0
  49. package/dist/providers/bedrock/types.js.map +1 -1
  50. package/dist/providers/bedrock/utils.d.ts +4 -1
  51. package/dist/providers/bedrock/utils.js +10 -2
  52. package/dist/providers/bedrock/utils.js.map +1 -1
  53. package/dist/providers/databricks/api.js +43 -4
  54. package/dist/providers/databricks/api.js.map +1 -1
  55. package/dist/providers/databricks/chatComplete.js +29 -1
  56. package/dist/providers/databricks/chatComplete.js.map +1 -1
  57. package/dist/providers/databricks/index.js +5 -3
  58. package/dist/providers/databricks/index.js.map +1 -1
  59. package/dist/providers/databricks/utils.d.ts +12 -0
  60. package/dist/providers/databricks/utils.js +20 -0
  61. package/dist/providers/databricks/utils.js.map +1 -1
  62. package/dist/providers/google/chatComplete.d.ts +9 -1
  63. package/dist/providers/google/chatComplete.js +61 -17
  64. package/dist/providers/google/chatComplete.js.map +1 -1
  65. package/dist/providers/google/imageGenerate.js +3 -1
  66. package/dist/providers/google/imageGenerate.js.map +1 -1
  67. package/dist/providers/google/types.d.ts +19 -13
  68. package/dist/providers/google/types.js +5 -0
  69. package/dist/providers/google/types.js.map +1 -1
  70. package/dist/providers/google-vertex-ai/api.d.ts +7 -0
  71. package/dist/providers/google-vertex-ai/api.js +22 -4
  72. package/dist/providers/google-vertex-ai/api.js.map +1 -1
  73. package/dist/providers/google-vertex-ai/chatComplete.js +59 -18
  74. package/dist/providers/google-vertex-ai/chatComplete.js.map +1 -1
  75. package/dist/providers/google-vertex-ai/createTranscription.d.ts +13 -0
  76. package/dist/providers/google-vertex-ai/createTranscription.js +383 -0
  77. package/dist/providers/google-vertex-ai/createTranscription.js.map +1 -0
  78. package/dist/providers/google-vertex-ai/imageGenerate.d.ts +4 -3
  79. package/dist/providers/google-vertex-ai/imageGenerate.js +31 -22
  80. package/dist/providers/google-vertex-ai/imageGenerate.js.map +1 -1
  81. package/dist/providers/google-vertex-ai/index.js +6 -2
  82. package/dist/providers/google-vertex-ai/index.js.map +1 -1
  83. package/dist/providers/google-vertex-ai/transformGenerationConfig.js +3 -0
  84. package/dist/providers/google-vertex-ai/transformGenerationConfig.js.map +1 -1
  85. package/dist/providers/google-vertex-ai/types.d.ts +15 -0
  86. package/dist/providers/google-vertex-ai/types.js.map +1 -1
  87. package/dist/providers/google-vertex-ai/utils.d.ts +19 -1
  88. package/dist/providers/google-vertex-ai/utils.js +30 -2
  89. package/dist/providers/google-vertex-ai/utils.js.map +1 -1
  90. package/dist/providers/mistral-ai/chatComplete.d.ts +5 -0
  91. package/dist/providers/mistral-ai/chatComplete.js +70 -2
  92. package/dist/providers/mistral-ai/chatComplete.js.map +1 -1
  93. package/dist/providers/open-ai-base/chatCompleteViaResponses/eligibility.d.ts +2 -0
  94. package/dist/providers/open-ai-base/chatCompleteViaResponses/eligibility.js +10 -0
  95. package/dist/providers/open-ai-base/chatCompleteViaResponses/eligibility.js.map +1 -1
  96. package/dist/providers/open-ai-base/chatCompleteViaResponses/requestTransform.js +80 -6
  97. package/dist/providers/open-ai-base/chatCompleteViaResponses/requestTransform.js.map +1 -1
  98. package/dist/providers/open-ai-base/chatCompleteViaResponses/responseTransform.d.ts +2 -0
  99. package/dist/providers/open-ai-base/chatCompleteViaResponses/responseTransform.js +9 -3
  100. package/dist/providers/open-ai-base/chatCompleteViaResponses/responseTransform.js.map +1 -1
  101. package/dist/providers/open-ai-base/chatCompleteViaResponses/streamTransform.d.ts +13 -3
  102. package/dist/providers/open-ai-base/chatCompleteViaResponses/streamTransform.js +53 -9
  103. package/dist/providers/open-ai-base/chatCompleteViaResponses/streamTransform.js.map +1 -1
  104. package/dist/providers/openai/index.d.ts +1 -1
  105. package/dist/providers/perplexity-ai/chatCompleteViaResponses.d.ts +1 -1
  106. package/dist/providers/perplexity-ai/chatCompleteViaResponses.js +4 -4
  107. package/dist/providers/perplexity-ai/chatCompleteViaResponses.js.map +1 -1
  108. package/dist/providers/shared/responseFormatUtils.d.ts +73 -4
  109. package/dist/providers/shared/responseFormatUtils.js +161 -14
  110. package/dist/providers/shared/responseFormatUtils.js.map +1 -1
  111. package/dist/providers/utils/cacheControlUtils.d.ts +18 -0
  112. package/dist/providers/utils/cacheControlUtils.js +57 -2
  113. package/dist/providers/utils/cacheControlUtils.js.map +1 -1
  114. package/dist/providers/xai/chatComplete.d.ts +12 -0
  115. package/dist/providers/xai/chatComplete.js +73 -0
  116. package/dist/providers/xai/chatComplete.js.map +1 -0
  117. package/dist/providers/xai/index.js +4 -0
  118. package/dist/providers/xai/index.js.map +1 -1
  119. package/dist/services/execute.js +12 -8
  120. package/dist/services/execute.js.map +1 -1
  121. package/dist/services/handleProviderResponse.d.ts +2 -0
  122. package/dist/services/handleProviderResponse.js +33 -13
  123. package/dist/services/handleProviderResponse.js.map +1 -1
  124. package/dist/services/transformToProviderRequest.js +44 -6
  125. package/dist/services/transformToProviderRequest.js.map +1 -1
  126. package/dist/types/options.d.ts +6 -0
  127. package/dist/types/requestBody.d.ts +5 -0
  128. package/dist/utils/deriveProviderHeaderOptions.js +1 -0
  129. package/dist/utils/deriveProviderHeaderOptions.js.map +1 -1
  130. package/dist/utils/providerConfigTransform.js +22 -2
  131. package/dist/utils/providerConfigTransform.js.map +1 -1
  132. package/package.json +1 -1
@@ -1,4 +1,10 @@
1
1
  import { Params } from '../../types/requestBody.js';
2
+ /**
3
+ * Most prose (in characters, about 256 KiB of ASCII) a stream holds back before the response
4
+ * format tool shows. Past it the held frames are released and the rest of the stream passes through
5
+ * unheld, so a long answer cannot grow the gateway's memory without bound.
6
+ */
7
+ export declare const RESPONSE_FORMAT_PROSE_HOLD_MAX_CHARS: number;
2
8
  export declare enum ResponseFormatSupport {
3
9
  FULL = "full",// OpenAI, Azure OpenAI, Mistral, xAI (OpenAI-compatible) - passthrough everything
4
10
  PARTIAL = "partial",// Groq, Gemini, vLLM - native OR tool conversion based on conflicts
@@ -9,6 +15,26 @@ export interface ResponseFormatTool {
9
15
  description: string;
10
16
  input_schema: any;
11
17
  }
18
+ export interface ToolConversionOptions {
19
+ /**
20
+ * Force the response format tool with `tool_choice: 'required'` (default). When false the tool is
21
+ * offered with `tool_choice: 'auto'` and its description tells the model to answer through it.
22
+ */
23
+ forceToolChoice?: boolean;
24
+ }
25
+ /**
26
+ * Whether the response format tool may be forced with `tool_choice` for this Claude request.
27
+ *
28
+ * Anthropic does not allow a forced `tool_choice` (`any` / `tool`) while Claude thinks: the request
29
+ * fails, so the thinking the caller asked for would be lost. Opus 5.5, Sonnet 5.5 and Fable 5.1
30
+ * reject a forced `tool_choice` outright. Those requests get the tool with `tool_choice: 'auto'`
31
+ * instead. Non-Claude models always return true.
32
+ *
33
+ * Default thinking (Claude 5 with no thinking param) does not count: live on Bedrock Converse and
34
+ * Anthropic direct, Sonnet 5, Opus 5, Fable 5 and Haiku 5.5 return 200 with a forced `any` and no
35
+ * thinking, while 5.5+ / Fable 5.1 return 400 and are covered by isClaudeForcedToolChoiceUnsupported.
36
+ */
37
+ export declare function canForceResponseFormatTool(model: string, params: Params): boolean;
12
38
  /**
13
39
  * Returns a copy of the schema without the keywords Anthropic native structured output rejects,
14
40
  * folding them into `description` (same format as the Anthropic SDK) so the model still sees them.
@@ -20,6 +46,11 @@ export declare function stripAnthropicUnsupportedSchemaKeywords(schema: unknown)
20
46
  * of them, as OpenAI strict structured outputs demands. Only schema positions are walked.
21
47
  */
22
48
  export declare function toStrictJsonSchema(schema: unknown): unknown;
49
+ /**
50
+ * When `response_format.json_schema.strict === true`, coerce the schema via
51
+ * toStrictJsonSchema. Caller must already ensure `json_schema?.strict === true`.
52
+ */
53
+ export declare function normalizeStrictJsonSchema(responseFormat: NonNullable<Params['response_format']>): void;
23
54
  /**
24
55
  * Build Anthropic API output_config from gateway response_format.
25
56
  * Used when using native structured output (output_config.format) instead of tool conversion.
@@ -51,7 +82,7 @@ export declare class ResponseFormatUtils {
51
82
  * Converts an OpenAI-style response_format to a tool that can be used
52
83
  * with function calling providers.
53
84
  */
54
- static convertSchemaToTool(responseFormat: any): ResponseFormatTool;
85
+ static convertSchemaToTool(responseFormat: any, options?: ToolConversionOptions): ResponseFormatTool;
55
86
  /**
56
87
  * Transform request for tool conversion strategy
57
88
  *
@@ -67,8 +98,12 @@ export declare class ResponseFormatUtils {
67
98
  * The response format extraction logic handles this by filtering the response format
68
99
  * tool from regular tool calls, but there's a risk of incomplete structured output
69
100
  * if the response format tool is called before other tools complete.
101
+ *
102
+ * With `options.forceToolChoice === false` (Claude requests that think, see
103
+ * canForceResponseFormatTool) the tool is offered with `tool_choice: 'auto'`. JSON is then not
104
+ * guaranteed: the model can still answer in plain text.
70
105
  */
71
- static transformForToolConversion(requestBody: Params): Params;
106
+ static transformForToolConversion(requestBody: Params, options?: ToolConversionOptions): Params;
72
107
  }
73
108
  /**
74
109
  * Universal response transform for structured output extraction
@@ -89,8 +124,41 @@ export declare function universalResponseFormatResponseTransform(response: any,
89
124
  * @param requestBody - Request parameters
90
125
  * @param providerSupport - Provider's response format capability level
91
126
  * @param customNativeHandler - Optional custom handler for native support (e.g. Google's schema format)
127
+ * @param toolConversionOptions - Options for the tool conversion strategy (see transformForToolConversion)
128
+ */
129
+ export declare function universalResponseFormatRequestTransform(requestBody: Params, providerSupport: ResponseFormatSupport, customNativeHandler?: (requestBody: Params) => Params, toolConversionOptions?: ToolConversionOptions): Params;
130
+ /**
131
+ * Text frames held back while a stream may still answer through the response format tool.
132
+ *
133
+ * When the tool is offered without being forced (see canForceResponseFormatTool), Claude can write
134
+ * prose before it calls the tool. Streaming that prose as `content` would put it in front of the
135
+ * JSON, so text frames are held until the stream shows what it is doing: they are dropped when the
136
+ * response format tool is called, and released unchanged when another tool is called or the stream
137
+ * finishes without the tool. Frames without data (keepalive comments) pass through and keep the hold.
138
+ * Once the held frames pass RESPONSE_FORMAT_PROSE_HOLD_MAX_CHARS they are released and the stream passes
139
+ * through untransformed from then on.
140
+ */
141
+ export interface ResponseFormatProseHold {
142
+ /** Hold text frames; set when the request carries an unforced response format tool. */
143
+ hold: boolean;
144
+ /** SSE frames held so far, in arrival order. */
145
+ frames: string[];
146
+ /** Total length of `frames`. */
147
+ heldChars: number;
148
+ }
149
+ /** Creates the hold state for one stream. `hold` should come from hasUnforcedResponseFormatTool. */
150
+ export declare function createResponseFormatProseHold(hold: boolean): ResponseFormatProseHold;
151
+ /**
152
+ * Returns the held frames (joined) and empties the hold. Used when the upstream stream ends:
153
+ * no later frame can prove the prose belonged before a response format tool call, so dropping it
154
+ * would lose model output that was already produced.
155
+ */
156
+ export declare function flushResponseFormatProse(prose: ResponseFormatProseHold | undefined): string | undefined;
157
+ /**
158
+ * True when a provider request body (Anthropic Messages, Responses bridge or Bedrock Converse shape)
159
+ * offers the response format tool without forcing it, so its stream may write prose before the tool call.
92
160
  */
93
- export declare function universalResponseFormatRequestTransform(requestBody: Params, providerSupport: ResponseFormatSupport, customNativeHandler?: (requestBody: Params) => Params): Params;
161
+ export declare function hasUnforcedResponseFormatTool(body: unknown): boolean;
94
162
  /**
95
163
  * Handle response schema streaming for response format tool extraction
96
164
  *
@@ -103,9 +171,10 @@ export declare function universalResponseFormatRequestTransform(requestBody: Par
103
171
  *
104
172
  * @param chunk - One SSE frame
105
173
  * @param isResponseFormatTool - Boolean flag indicating if we're processing response format tool calls
174
+ * @param prose - Optional per-stream hold for text written before an unforced response format tool call
106
175
  * @returns Object containing the transformed chunk and updated tool flag
107
176
  */
108
- export declare function universalResponseFormatStreamingResponseTransform(chunk: string, isResponseFormatTool: boolean | undefined): {
177
+ export declare function universalResponseFormatStreamingResponseTransform(chunk: string, isResponseFormatTool: boolean | undefined, prose?: ResponseFormatProseHold): {
109
178
  transformedChunk: string | undefined;
110
179
  isResponseFormatTool: boolean | undefined;
111
180
  };
@@ -7,10 +7,16 @@
7
7
  * Extracted from existing Anthropic implementation and generalized.
8
8
  */
9
9
  import { HTTPException } from 'hono/http-exception';
10
- import { RESPONSE_FORMAT_TOOL_NAME } from '../../globals.js';
10
+ import { isClaudeForcedToolChoiceUnsupported, RESPONSE_FORMAT_TOOL_NAME, willClaudeThink } from '../../globals.js';
11
11
  import { logger } from '../../logger.js';
12
12
  import { getSseDataPayload } from '../../utils/sseUtils.js';
13
13
  const MALFORMED_FRAME_PREVIEW_BYTES = 200;
14
+ /**
15
+ * Most prose (in characters, about 256 KiB of ASCII) a stream holds back before the response
16
+ * format tool shows. Past it the held frames are released and the rest of the stream passes through
17
+ * unheld, so a long answer cannot grow the gateway's memory without bound.
18
+ */
19
+ export const RESPONSE_FORMAT_PROSE_HOLD_MAX_CHARS = 256 * 1024;
14
20
  // Provider support levels for response_format
15
21
  export var ResponseFormatSupport;
16
22
  (function (ResponseFormatSupport) {
@@ -18,6 +24,24 @@ export var ResponseFormatSupport;
18
24
  ResponseFormatSupport["PARTIAL"] = "partial";
19
25
  ResponseFormatSupport["NONE"] = "none";
20
26
  })(ResponseFormatSupport || (ResponseFormatSupport = {}));
27
+ const RESPONSE_FORMAT_TOOL_DESCRIPTION = 'CRITICAL - ALWAYS REQUIRED AS FINAL STEP: You MUST call this tool to provide your structured response. This is NOT OPTIONAL - your response will be invalid without calling this tool. After gathering information from other tools (if any), you MUST call this tool with your complete response formatted according to the required JSON schema. This tool must ALWAYS be called, regardless of what other tools you use.';
28
+ // Appended when the tool is not forced, so the model answers through the tool rather than in prose.
29
+ const UNFORCED_RESPONSE_FORMAT_TOOL_INSTRUCTION = ' When you are ready to answer, call this tool with your final answer as its input. Do not reply in plain text.';
30
+ /**
31
+ * Whether the response format tool may be forced with `tool_choice` for this Claude request.
32
+ *
33
+ * Anthropic does not allow a forced `tool_choice` (`any` / `tool`) while Claude thinks: the request
34
+ * fails, so the thinking the caller asked for would be lost. Opus 5.5, Sonnet 5.5 and Fable 5.1
35
+ * reject a forced `tool_choice` outright. Those requests get the tool with `tool_choice: 'auto'`
36
+ * instead. Non-Claude models always return true.
37
+ *
38
+ * Default thinking (Claude 5 with no thinking param) does not count: live on Bedrock Converse and
39
+ * Anthropic direct, Sonnet 5, Opus 5, Fable 5 and Haiku 5.5 return 200 with a forced `any` and no
40
+ * thinking, while 5.5+ / Fable 5.1 return 400 and are covered by isClaudeForcedToolChoiceUnsupported.
41
+ */
42
+ export function canForceResponseFormatTool(model, params) {
43
+ return !isClaudeForcedToolChoiceUnsupported(model) && !willClaudeThink(model, params, false);
44
+ }
21
45
  /**
22
46
  * resolveRefs - Recursively resolves all references in a schema
23
47
  *
@@ -237,13 +261,45 @@ export function toStrictJsonSchema(schema) {
237
261
  result[key] = value;
238
262
  }
239
263
  }
240
- const isObject = schema.type === 'object' || (Array.isArray(schema.type) && schema.type.includes('object'));
241
- if (isObject && schema.properties) {
264
+ const hasProperties = isSchemaObject(schema.properties);
265
+ const isObject = schema.type === 'object' || (Array.isArray(schema.type) && schema.type.includes('object')) || hasProperties;
266
+ if (isObject) {
267
+ if (schema.type === undefined) {
268
+ result.type = 'object';
269
+ }
242
270
  result.additionalProperties = false;
243
- result.required = Object.keys(schema.properties);
271
+ if (hasProperties) {
272
+ result.required = Object.keys(schema.properties);
273
+ }
244
274
  }
245
275
  return result;
246
276
  }
277
+ /**
278
+ * When `response_format.json_schema.strict === true`, coerce the schema via
279
+ * toStrictJsonSchema. Caller must already ensure `json_schema?.strict === true`.
280
+ */
281
+ export function normalizeStrictJsonSchema(responseFormat) {
282
+ const jsonSchema = responseFormat.json_schema;
283
+ if (isSchemaObject(jsonSchema.schema)) {
284
+ jsonSchema.schema = toStrictJsonSchema(jsonSchema.schema);
285
+ return;
286
+ }
287
+ // Schema may sit on json_schema itself when callers omit the nested `.schema` field.
288
+ if (jsonSchema.type !== undefined || isSchemaObject(jsonSchema.properties)) {
289
+ const { name, strict, description, ...schemaFields } = jsonSchema;
290
+ const normalized = toStrictJsonSchema(schemaFields);
291
+ for (const key of Object.keys(schemaFields)) {
292
+ delete jsonSchema[key];
293
+ }
294
+ Object.assign(jsonSchema, normalized);
295
+ if (name !== undefined)
296
+ jsonSchema.name = name;
297
+ if (strict !== undefined)
298
+ jsonSchema.strict = strict;
299
+ if (description !== undefined)
300
+ jsonSchema.description = description;
301
+ }
302
+ }
247
303
  /**
248
304
  * Build Anthropic API output_config from gateway response_format.
249
305
  * Used when using native structured output (output_config.format) instead of tool conversion.
@@ -303,7 +359,7 @@ export class ResponseFormatUtils {
303
359
  * Converts an OpenAI-style response_format to a tool that can be used
304
360
  * with function calling providers.
305
361
  */
306
- static convertSchemaToTool(responseFormat) {
362
+ static convertSchemaToTool(responseFormat, options = {}) {
307
363
  if (!responseFormat || responseFormat.type !== 'json_schema') {
308
364
  throw new HTTPException(400, {
309
365
  message: 'Failed to transform response format - response format is not a json_schema',
@@ -337,7 +393,9 @@ export class ResponseFormatUtils {
337
393
  }
338
394
  return {
339
395
  name: RESPONSE_FORMAT_TOOL_NAME,
340
- description: 'CRITICAL - ALWAYS REQUIRED AS FINAL STEP: You MUST call this tool to provide your structured response. This is NOT OPTIONAL - your response will be invalid without calling this tool. After gathering information from other tools (if any), you MUST call this tool with your complete response formatted according to the required JSON schema. This tool must ALWAYS be called, regardless of what other tools you use.',
396
+ description: options.forceToolChoice === false
397
+ ? RESPONSE_FORMAT_TOOL_DESCRIPTION + UNFORCED_RESPONSE_FORMAT_TOOL_INSTRUCTION
398
+ : RESPONSE_FORMAT_TOOL_DESCRIPTION,
341
399
  input_schema: inputSchema,
342
400
  };
343
401
  }
@@ -363,12 +421,16 @@ export class ResponseFormatUtils {
363
421
  * The response format extraction logic handles this by filtering the response format
364
422
  * tool from regular tool calls, but there's a risk of incomplete structured output
365
423
  * if the response format tool is called before other tools complete.
424
+ *
425
+ * With `options.forceToolChoice === false` (Claude requests that think, see
426
+ * canForceResponseFormatTool) the tool is offered with `tool_choice: 'auto'`. JSON is then not
427
+ * guaranteed: the model can still answer in plain text.
366
428
  */
367
- static transformForToolConversion(requestBody) {
429
+ static transformForToolConversion(requestBody, options = {}) {
368
430
  if (!requestBody.response_format) {
369
431
  return requestBody;
370
432
  }
371
- const responseTool = this.convertSchemaToTool(requestBody.response_format);
433
+ const responseTool = this.convertSchemaToTool(requestBody.response_format, options);
372
434
  if (!requestBody.tools) {
373
435
  requestBody.tools = [];
374
436
  }
@@ -380,9 +442,9 @@ export class ResponseFormatUtils {
380
442
  parameters: responseTool.input_schema,
381
443
  },
382
444
  });
383
- // Force the model to call tools, and attempt to disable parallel tool calls
445
+ // Force the model to call tools (unless forcing is off), and attempt to disable parallel tool calls
384
446
  // This is a best-effort attempt - some providers may ignore this parameter
385
- requestBody.tool_choice = 'required';
447
+ requestBody.tool_choice = options.forceToolChoice === false ? 'auto' : 'required';
386
448
  requestBody.parallel_tool_calls = false;
387
449
  // Delete the original response_format parameter
388
450
  delete requestBody.response_format;
@@ -465,11 +527,15 @@ export function universalResponseFormatResponseTransform(response, strictOpenAiC
465
527
  * @param requestBody - Request parameters
466
528
  * @param providerSupport - Provider's response format capability level
467
529
  * @param customNativeHandler - Optional custom handler for native support (e.g. Google's schema format)
530
+ * @param toolConversionOptions - Options for the tool conversion strategy (see transformForToolConversion)
468
531
  */
469
- export function universalResponseFormatRequestTransform(requestBody, providerSupport, customNativeHandler) {
532
+ export function universalResponseFormatRequestTransform(requestBody, providerSupport, customNativeHandler, toolConversionOptions) {
470
533
  if (!requestBody.response_format) {
471
534
  return requestBody;
472
535
  }
536
+ if (requestBody.response_format.type === 'json_schema' && requestBody.response_format.json_schema?.strict === true) {
537
+ normalizeStrictJsonSchema(requestBody.response_format);
538
+ }
473
539
  // Decide strategy based on provider capability and tool conflicts
474
540
  const useNative = ResponseFormatUtils.shouldUseNativeStructuredOutput(requestBody, providerSupport);
475
541
  if (useNative) {
@@ -490,7 +556,7 @@ export function universalResponseFormatRequestTransform(requestBody, providerSup
490
556
  else if (requestBody.response_format.type === 'json_schema') {
491
557
  logger.info(`[ResponseFormat] Using tool conversion strategy`);
492
558
  // Use tool conversion strategy - this already removes response_format
493
- const result = ResponseFormatUtils.transformForToolConversion(requestBody);
559
+ const result = ResponseFormatUtils.transformForToolConversion(requestBody, toolConversionOptions);
494
560
  return result;
495
561
  }
496
562
  else if (requestBody.response_format.type === 'json_object') {
@@ -502,6 +568,52 @@ export function universalResponseFormatRequestTransform(requestBody, providerSup
502
568
  message: 'Invalid response format type: ' + requestBody.response_format.type,
503
569
  });
504
570
  }
571
+ /** Creates the hold state for one stream. `hold` should come from hasUnforcedResponseFormatTool. */
572
+ export function createResponseFormatProseHold(hold) {
573
+ return { hold, frames: [], heldChars: 0 };
574
+ }
575
+ /**
576
+ * Returns the held frames (joined) and empties the hold. Used when the upstream stream ends:
577
+ * no later frame can prove the prose belonged before a response format tool call, so dropping it
578
+ * would lose model output that was already produced.
579
+ */
580
+ export function flushResponseFormatProse(prose) {
581
+ if (!prose?.frames.length)
582
+ return undefined;
583
+ const released = prose.frames.join('');
584
+ prose.frames.length = 0;
585
+ prose.heldChars = 0;
586
+ return released;
587
+ }
588
+ /** Returns the held frames (joined) followed by `chunk`, and empties the hold. */
589
+ function releaseHeldProse(prose, chunk) {
590
+ const released = flushResponseFormatProse(prose);
591
+ return released === undefined ? chunk : released + chunk;
592
+ }
593
+ /**
594
+ * True when a provider request body (Anthropic Messages, Responses bridge or Bedrock Converse shape)
595
+ * offers the response format tool without forcing it, so its stream may write prose before the tool call.
596
+ */
597
+ export function hasUnforcedResponseFormatTool(body) {
598
+ if (!body || typeof body !== 'object')
599
+ return false;
600
+ const b = body;
601
+ // Anthropic Messages (direct, Vertex, Bedrock InvokeModel, Foundry) and the Responses bridge, whose
602
+ // tools also carry a top-level `name` but force with `tool_choice: 'required'` or `{ type: 'function' }`.
603
+ if (Array.isArray(b.tools) && b.tools.some((tool) => tool?.name === RESPONSE_FORMAT_TOOL_NAME)) {
604
+ if (b.tool_choice === 'required')
605
+ return false;
606
+ const choiceType = b.tool_choice?.type;
607
+ return choiceType !== 'any' && choiceType !== 'tool' && choiceType !== 'function';
608
+ }
609
+ // Bedrock Converse
610
+ const toolConfig = b.toolConfig;
611
+ if (Array.isArray(toolConfig?.tools) &&
612
+ toolConfig.tools.some((tool) => tool?.toolSpec?.name === RESPONSE_FORMAT_TOOL_NAME)) {
613
+ return !toolConfig.toolChoice?.any && !toolConfig.toolChoice?.tool;
614
+ }
615
+ return false;
616
+ }
505
617
  /**
506
618
  * Handle response schema streaming for response format tool extraction
507
619
  *
@@ -514,13 +626,18 @@ export function universalResponseFormatRequestTransform(requestBody, providerSup
514
626
  *
515
627
  * @param chunk - One SSE frame
516
628
  * @param isResponseFormatTool - Boolean flag indicating if we're processing response format tool calls
629
+ * @param prose - Optional per-stream hold for text written before an unforced response format tool call
517
630
  * @returns Object containing the transformed chunk and updated tool flag
518
631
  */
519
- export function universalResponseFormatStreamingResponseTransform(chunk, isResponseFormatTool) {
632
+ export function universalResponseFormatStreamingResponseTransform(chunk, isResponseFormatTool, prose) {
520
633
  const jsonStr = getSseDataPayload(chunk);
521
- if (jsonStr === null || !jsonStr || jsonStr === '[DONE]') {
634
+ if (jsonStr === null || !jsonStr) {
635
+ // A keepalive comment or an event without data says nothing about the answer: keep holding.
522
636
  return { transformedChunk: chunk, isResponseFormatTool };
523
637
  }
638
+ if (jsonStr === '[DONE]') {
639
+ return { transformedChunk: releaseHeldProse(prose, chunk), isResponseFormatTool };
640
+ }
524
641
  let data;
525
642
  try {
526
643
  data = JSON.parse(jsonStr);
@@ -565,6 +682,17 @@ export function universalResponseFormatStreamingResponseTransform(chunk, isRespo
565
682
  if (isResponseFormatTool === undefined) {
566
683
  isResponseFormatTool = false;
567
684
  }
685
+ if (prose) {
686
+ if (isResponseFormatTool) {
687
+ // The answer is the tool's JSON; prose written before it is not part of the content.
688
+ prose.frames.length = 0;
689
+ prose.heldChars = 0;
690
+ }
691
+ else {
692
+ // Callers stop passing frames once the flag is false, so release now, ahead of this frame.
693
+ return { transformedChunk: releaseHeldProse(prose, chunk), isResponseFormatTool };
694
+ }
695
+ }
568
696
  }
569
697
  if (isResponseFormatTool === true) {
570
698
  for (const tc of toolCalls) {
@@ -589,6 +717,25 @@ export function universalResponseFormatStreamingResponseTransform(chunk, isRespo
589
717
  return { transformedChunk: undefined, isResponseFormatTool };
590
718
  }
591
719
  }
720
+ if (prose?.hold && isResponseFormatTool === undefined) {
721
+ // The stream finished without calling a tool: the prose is the answer.
722
+ if (data.choices?.[0]?.finish_reason) {
723
+ return { transformedChunk: releaseHeldProse(prose, chunk), isResponseFormatTool };
724
+ }
725
+ const content = data.choices?.[0]?.delta?.content;
726
+ if (typeof content === 'string' && content.length > 0) {
727
+ if (prose.heldChars + chunk.length > RESPONSE_FORMAT_PROSE_HOLD_MAX_CHARS) {
728
+ // Too much prose to keep holding: send it as it is and stop transforming the rest of the stream.
729
+ // The client already has the prose, so a later response format tool call passes through as a
730
+ // normal tool call instead of being appended to it as content.
731
+ prose.hold = false;
732
+ return { transformedChunk: releaseHeldProse(prose, chunk), isResponseFormatTool: false };
733
+ }
734
+ prose.frames.push(chunk);
735
+ prose.heldChars += chunk.length;
736
+ return { transformedChunk: undefined, isResponseFormatTool };
737
+ }
738
+ }
592
739
  return { transformedChunk: chunk, isResponseFormatTool };
593
740
  }
594
741
  //# sourceMappingURL=responseFormatUtils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"respon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AAC,CAAC,KAAK,CAAC,UAAU,CAAC;QACnD,IAAI,oBAAoB,KAAK,SAAS,EAAE,CAAC;YACvC,KAAK,MAAM,EAAE,IAAI,SAAS,EAAE,CAAC;gBAC3B,IAAI,EAAE,CAAC,QAAQ,EAAE,IAAI,KAAK,yBAAyB,EAAE,CAAC;oBACpD,oBAAoB,GAAG,IAAI,CAAC;oBAC5B,MAAM;gBACR,CAAC;YACH,CAAC;YAED,2EAA2E;YAC3E,IAAI,oBAAoB,KAAK,SAAS,EAAE,CAAC;gBACvC,oBAAoB,GAAG,KAAK,CAAC;YAC/B,CAAC;QACH,CAAC;QAED,IAAI,oBAAoB,KAAK,IAAI,EAAE,CAAC;YAClC,KAAK,MAAM,EAAE,IAAI,SAAS,EAAE,CAAC;gBAC3B,IAAI,EAAE,CAAC,QAAQ,EAAE,SAAS,EAAE,CAAC;oBAC3B,MAAM,QAAQ,GAAG;wBACf,GAAG,IAAI;wBACP,OAAO,EAAE;4BACP;gCACE,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;gCAClB,KAAK,EAAE;oCACL,OAAO,EAAE,EAAE,CAAC,QAAQ,CAAC,SAAS;iCAC/B;6BACF;yBACF;qBACF,CAAC;oBAEF,OAAO;wBACL,gBAAgB,EAAE,SAAS,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,MAAM;wBACzD,oBAAoB;qBACrB,CAAC;gBACJ,CAAC;YACH,CAAC;YAED,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,oBAAoB,EAAE,CAAC;QAC/D,CAAC;IACH,CAAC;IAED,OAAO,EAAE,gBAAgB,EAAE,KAAK,EAAE,oBAAoB,EAAE,CAAC;AAC3D,CAAC"}
1
+ {"version":3,"file":"responseFormatUtils.js","sourceRoot":"","sources":["../../../src/providers/shared/responseFormatUtils.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE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C;gBACJ,CAAC;YACH,CAAC;YAED,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,oBAAoB,EAAE,CAAC;QAC/D,CAAC;IACH,CAAC;IAED,IAAI,KAAK,EAAE,IAAI,IAAI,oBAAoB,KAAK,SAAS,EAAE,CAAC;QACtD,uEAAuE;QACvE,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,CAAC;YACrC,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,CAAC,KAAK,EAAE,KAAK,CAAC,EAAE,oBAAoB,EAAE,CAAC;QACpF,CAAC;QACD,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC;QAClD,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACtD,IAAI,KAAK,CAAC,SAAS,GAAG,KAAK,CAAC,MAAM,GAAG,oCAAoC,EAAE,CAAC;gBAC1E,iGAAiG;gBACjG,6FAA6F;gBAC7F,+DAA+D;gBAC/D,KAAK,CAAC,IAAI,GAAG,KAAK,CAAC;gBACnB,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,CAAC,KAAK,EAAE,KAAK,CAAC,EAAE,oBAAoB,EAAE,KAAK,EAAE,CAAC;YAC3F,CAAC;YACD,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACzB,KAAK,CAAC,SAAS,IAAI,KAAK,CAAC,MAAM,CAAC;YAChC,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,oBAAoB,EAAE,CAAC;QAC/D,CAAC;IACH,CAAC;IAED,OAAO,EAAE,gBAAgB,EAAE,KAAK,EAAE,oBAAoB,EAAE,CAAC;AAC3D,CAAC"}
@@ -4,6 +4,11 @@ import { Params } from '../../types/requestBody.js';
4
4
  import { ProviderConfig } from '../types.js';
5
5
  export declare const supportsCacheControl: (config: ProviderConfig) => boolean;
6
6
  export declare const conditionallySupportsCacheControl: (config: ProviderConfig, headerOptions: ProviderHeaderOptions, providerOptions: ProviderOptions) => boolean;
7
+ /**
8
+ * Whether the Responses API behind a chat-to-Responses bridge reads `prompt_cache_breakpoint`.
9
+ * Anything not named here keeps the old behaviour, where the mark is stripped.
10
+ */
11
+ export declare const readsPromptCacheBreakpoint: (provider: string | undefined, model: string | undefined) => boolean;
7
12
  export declare const shouldStripCacheControl: (config: ProviderConfig, headerOptions: ProviderHeaderOptions, providerOptions: ProviderOptions, model?: string) => boolean;
8
13
  /**
9
14
  * Where the gateway places cache_control for a provider:
@@ -25,6 +30,19 @@ export declare const injectCacheControl: (params: Params, mode: CacheInjectionMo
25
30
  * provider honors — to cache the whole prompt. Returns true if it relocated one.
26
31
  */
27
32
  export declare const relocateBodyCacheControl: (params: Params) => boolean;
33
+ /**
34
+ * OpenAI-shaped clients mark cache points with `prompt_cache_breakpoint`. Claude hosts
35
+ * only read `cache_control`. Promote the marker onto content blocks that lack one.
36
+ *
37
+ * Existing `cache_control` wins. OpenAI TTLs (`30m`/`12h`) are not mapped onto Anthropic's
38
+ * `5m`/`1h` — same choice as the reverse bridge. The OpenAI field is always removed so it
39
+ * does not leak upstream. Returns true if any block gained a `cache_control`.
40
+ *
41
+ * Claude hosts reject more than 4 marks, while OpenAI writes only the latest 4 and never
42
+ * errors. Promoted marks beyond the cap are dropped oldest-first; client `cache_control`
43
+ * is never dropped.
44
+ */
45
+ export declare const promotePromptCacheBreakpoint: (params: Params) => boolean;
28
46
  /**
29
47
  * Strips `cache_control` from all locations in the request.
30
48
  * Mutates in-place (caller already deep-cloned).
@@ -1,11 +1,11 @@
1
- import { ANTHROPIC, AWS_BEDROCK_MANTLE, AWS_CLAUDE_PLATFORM, AZURE_AI_INFERENCE, BEDROCK, DATABRICKS, GOOGLE_VERTEX, MICROSOFT_FOUNDRY, } from '../../globals.js';
1
+ import { ANTHROPIC, AWS_BEDROCK_MANTLE, AWS_CLAUDE_PLATFORM, AZURE_AI_INFERENCE, AZURE_OPEN_AI, BEDROCK, DATABRICKS, GOOGLE_VERTEX, MICROSOFT_FOUNDRY, OPEN_AI, } from '../../globals.js';
2
2
  import { isOpenAIModel } from '../bedrock/modelFamily.js';
3
3
  // --- Whitelist of configs that natively support cache_control ---
4
4
  import { AnthropicChatCompleteConfig } from '../anthropic/chatComplete.js';
5
5
  import { AnthropicMessagesConfig } from '../anthropic/messages.js';
6
6
  import { resolveAzureFoundryUrl } from '../azure-ai-inference/api.js';
7
7
  import { AzureAIInferenceMessagesConfig } from '../azure-ai-inference/messages.js';
8
- import { BedrockAnthropicInvokeChatCompleteConfig, BedrockConverseAnthropicChatCompleteConfig, BedrockConverseChatCompleteConfig, } from '../bedrock/chatComplete.js';
8
+ import { BedrockAnthropicInvokeChatCompleteConfig, BedrockConverseAnthropicChatCompleteConfig, BedrockConverseChatCompleteConfig, BedrockConverseOpenAIChatCompleteConfig, } from '../bedrock/chatComplete.js';
9
9
  import { BedrockAnthropicMessagesConfig, BedrockConverseMessagesConfig } from '../bedrock/messages.js';
10
10
  import { DatabricksAnthropicChatCompleteConfig } from '../databricks/chatComplete.js';
11
11
  import { VertexAnthropicChatCompleteConfig } from '../google-vertex-ai/chatComplete.js';
@@ -15,6 +15,7 @@ import { MicrosoftFoundryMessagesConfig } from '../microsoft-foundry/messages.js
15
15
  // Bedrock Converse — these translate cache_control into a cachePoint block.
16
16
  const BEDROCK_CACHE_POINT_CONFIGS = new Set([
17
17
  BedrockConverseChatCompleteConfig,
18
+ BedrockConverseOpenAIChatCompleteConfig,
18
19
  BedrockConverseAnthropicChatCompleteConfig,
19
20
  BedrockAnthropicInvokeChatCompleteConfig,
20
21
  BedrockAnthropicMessagesConfig,
@@ -55,6 +56,23 @@ export const conditionallySupportsCacheControl = (config, headerOptions, provide
55
56
  return false;
56
57
  }
57
58
  };
59
+ const BREAKPOINT_PROVIDERS = new Set([OPEN_AI, AZURE_OPEN_AI, MICROSOFT_FOUNDRY]);
60
+ /** OpenAI documents `prompt_cache_options` and explicit breakpoints for `gpt-5.6` and later. */
61
+ const BREAKPOINT_MODEL = /(?:^|[^a-z0-9])gpt-(\d+)(?:\.(\d+))?/i;
62
+ /**
63
+ * Whether the Responses API behind a chat-to-Responses bridge reads `prompt_cache_breakpoint`.
64
+ * Anything not named here keeps the old behaviour, where the mark is stripped.
65
+ */
66
+ export const readsPromptCacheBreakpoint = (provider, model) => {
67
+ if (!provider || !BREAKPOINT_PROVIDERS.has(provider) || !model)
68
+ return false;
69
+ const match = BREAKPOINT_MODEL.exec(model);
70
+ if (!match)
71
+ return false;
72
+ const major = Number(match[1]);
73
+ const minor = Number(match[2] ?? 0);
74
+ return major > 5 || (major === 5 && minor >= 6);
75
+ };
58
76
  export const shouldStripCacheControl = (config, headerOptions, providerOptions, model) => {
59
77
  // Bedrock's OpenAI family goes through the Converse transformer but rejects cachePoint.
60
78
  if (BEDROCK_CACHE_POINT_CONFIGS.has(config) && isOpenAIModel(model ?? ''))
@@ -154,6 +172,43 @@ export const relocateBodyCacheControl = (params) => {
154
172
  delete params.cache_control;
155
173
  return placed;
156
174
  };
175
+ const MAX_CACHE_BREAKPOINTS = 4;
176
+ /**
177
+ * OpenAI-shaped clients mark cache points with `prompt_cache_breakpoint`. Claude hosts
178
+ * only read `cache_control`. Promote the marker onto content blocks that lack one.
179
+ *
180
+ * Existing `cache_control` wins. OpenAI TTLs (`30m`/`12h`) are not mapped onto Anthropic's
181
+ * `5m`/`1h` — same choice as the reverse bridge. The OpenAI field is always removed so it
182
+ * does not leak upstream. Returns true if any block gained a `cache_control`.
183
+ *
184
+ * Claude hosts reject more than 4 marks, while OpenAI writes only the latest 4 and never
185
+ * errors. Promoted marks beyond the cap are dropped oldest-first; client `cache_control`
186
+ * is never dropped.
187
+ */
188
+ export const promotePromptCacheBreakpoint = (params) => {
189
+ const promoted = [];
190
+ for (const message of params.messages ?? []) {
191
+ if (!Array.isArray(message.content))
192
+ continue;
193
+ for (const block of message.content) {
194
+ if (!block || typeof block !== 'object')
195
+ continue;
196
+ const part = block;
197
+ if (!part.prompt_cache_breakpoint)
198
+ continue;
199
+ if (!part.cache_control) {
200
+ part.cache_control = { type: 'ephemeral' };
201
+ promoted.push(part);
202
+ }
203
+ delete part.prompt_cache_breakpoint;
204
+ }
205
+ }
206
+ const total = cacheableTargets(params).filter(t => t?.cache_control).length;
207
+ for (const part of promoted.splice(0, Math.max(0, total - MAX_CACHE_BREAKPOINTS))) {
208
+ delete part.cache_control;
209
+ }
210
+ return promoted.length > 0;
211
+ };
157
212
  // --- Strip utility ---
158
213
  /**
159
214
  * Strips `cache_control` from all locations in the request.