@sixb/azure-ai-foundry 0.2.0 → 0.2.4

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 { type JsonObject, type LanguageModelDefinition, type LanguageModelRequest } from "@sixb/core/models";
2
+ import { StrictToolRefusals } from "@sixb/model-protocols/messages";
2
3
  export interface MessagesRequestOptions {
3
4
  readonly maxOutputTokens?: number;
4
5
  readonly maxInputFileBytes?: number;
@@ -6,6 +7,18 @@ export interface MessagesRequestOptions {
6
7
  /** Explicitly restrict thinking serialization to adaptive or manual mode. */
7
8
  readonly thinkingMode?: "adaptive" | "manual";
8
9
  }
10
+ /** Strict tool sets Claude on Foundry refused: sent unconstrained from the start next time. */
11
+ export declare const strictToolRefusals: StrictToolRefusals;
12
+ export interface FoundryMessagesRequest {
13
+ readonly body: JsonObject;
14
+ /** The key of the strict tools it sends, if any, for {@link strictToolRefusals}. */
15
+ readonly strictTools?: string;
16
+ }
9
17
  export declare function validateMessagesOptions(options: MessagesRequestOptions): void;
10
- export declare function foundryMessagesRequest(request: LanguageModelRequest, definition: LanguageModelDefinition, options: MessagesRequestOptions, scope: string): JsonObject;
18
+ /**
19
+ * `unconstrained`: no strict tools, as after Claude refused this request's. Otherwise a tool is
20
+ * strict when it asks, the deployment declares native structured output, and it fits Anthropic's
21
+ * limits, in order (`messagesStrictTools`).
22
+ */
23
+ export declare function foundryMessagesRequest(request: LanguageModelRequest, definition: LanguageModelDefinition, options: MessagesRequestOptions, scope: string, unconstrained?: boolean): FoundryMessagesRequest;
11
24
  //# sourceMappingURL=messages-request.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"messages-request.d.ts","sourceRoot":"","sources":["../src/messages-request.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,UAAU,EACf,KAAK,uBAAuB,EAC5B,KAAK,oBAAoB,EAG1B,MAAM,mBAAmB,CAAA;AAM1B,MAAM,WAAW,sBAAsB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A8B,GACtC,4BAA4B,CAAA;IAC/B,QAAQ,CAAC,OAAO,EAAE,qBAAqB,CAAA;IACvC,IAAI,CAAC,cAAc,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,yBAAyB,GAAG,mBAAmB,CAAC,MAAM,CAAC,CAAA;CAC/F;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,qBAAqB,GAAG,sBAAsB,CA6F3F"}
package/dist/request.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { type JsonObject, type LanguageModelDefinition, type LanguageModelRequest, type ModelMessage } from "@sixb/core/models";
1
+ import { type JsonObject, type LanguageModelDefinition, type LanguageModelRequest, type ModelMessage, type ModelToolSpecification } from "@sixb/core/models";
2
2
  import type { AzureAIFoundryDeployment } from "./discovery";
3
3
  export interface RequestOptions {
4
4
  readonly maxOutputTokens?: number;
@@ -17,4 +17,9 @@ export declare function prepareRequest(request: LanguageModelRequest, definition
17
17
  readonly maxInputFileBytes?: number;
18
18
  }, scope: string, remotePdf?: boolean): number | undefined;
19
19
  export declare function validateMessages(messages: readonly ModelMessage[], definition: LanguageModelDefinition, budget: number, scope: string, remotePdf?: boolean): void;
20
+ /**
21
+ * A tool that asked for strict arguments, in the form OpenAI's strict mode takes (every property
22
+ * required, an optional one nullable), when it fits Azure's strict subset.
23
+ */
24
+ export declare function foundryStrictTool(tool: ModelToolSpecification): JsonObject | undefined;
20
25
  //# sourceMappingURL=request.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../src/request.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,UAAU,EACf,KAAK,uBAAuB,EAC5B,KAAK,oBAAoB,EACzB,KAAK,YAAY,EAGlB,MAAM,mBAAmB,CAAA;AAE1B,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAA;AAI3D,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAA;IACjC,QA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AAAA,OAAO,EAAgB,KAAK,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAkBjE,uFAAuF;AACvF,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,GAAG,SAAS,CAmH9E"}
1
+ {"version":3,"file":"structured-output.d.ts","sourceRoot":"","sources":["../src/structured-output.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,UAAU,EAAE,MAAM,mBAAmB,CAAA;AA0BjE,uFAAuF;AACvF,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,GAAG,SAAS,CAmH9E"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sixb/azure-ai-foundry",
3
- "version": "0.2.0",
3
+ "version": "0.2.4",
4
4
  "description": "Azure AI Foundry model provider for Sixb",
5
5
  "homepage": "https://sixb.ai",
6
6
  "bugs": {
@@ -31,8 +31,8 @@
31
31
  "prepack": "bun run build"
32
32
  },
33
33
  "dependencies": {
34
- "@sixb/core": "^0.2.0",
35
- "@sixb/model-protocols": "0.2.0"
34
+ "@sixb/core": "^0.2.4",
35
+ "@sixb/model-protocols": "0.2.4"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@types/bun": "latest",
@@ -6,7 +6,7 @@ import {
6
6
  UnsupportedModelFeatureError,
7
7
  } from "@sixb/core/models"
8
8
  import { chatInput } from "@sixb/model-protocols/chat"
9
- import { prepareRequest } from "./request"
9
+ import { foundryStrictTool, prepareRequest } from "./request"
10
10
  import { foundryOutputSchema } from "./structured-output"
11
11
  import { PREFIX, positiveInteger } from "./util"
12
12
 
@@ -100,21 +100,21 @@ export function foundryChatRequest(
100
100
  throw new UnsupportedModelFeatureError(
101
101
  `${PREFIX} Chat structured output requires verified OpenAI-compatible strict-schema support. DeepSeek JSON mode is not strict schema decoding.`
102
102
  )
103
- const tools = request.tools.map((tool) => ({
104
- type: "function",
105
- function: {
106
- name: tool.name,
107
- description: tool.description,
108
- parameters: tool.inputSchema,
109
- ...(profile === "openai"
110
- ? {
111
- strict:
112
- caps.nativeStructuredOutput === true &&
113
- foundryOutputSchema(tool.inputSchema) !== undefined,
114
- }
115
- : {}),
116
- },
117
- }))
103
+ const tools = request.tools.map((tool) => {
104
+ const strict =
105
+ profile === "openai" && caps.nativeStructuredOutput === true
106
+ ? foundryStrictTool(tool)
107
+ : undefined
108
+ return {
109
+ type: "function",
110
+ function: {
111
+ name: tool.name,
112
+ description: tool.description,
113
+ parameters: strict ?? tool.inputSchema,
114
+ ...(profile === "openai" ? { strict: strict !== undefined } : {}),
115
+ },
116
+ }
117
+ })
118
118
  return {
119
119
  ...options.request,
120
120
  model: definition.modelId,
@@ -134,10 +134,8 @@ export function foundryChatRequest(
134
134
  tool_choice: "auto",
135
135
  ...(profile === "openai"
136
136
  ? {
137
- parallel_tool_calls:
138
- !schema &&
139
- !tools.some((tool) => tool.function.strict) &&
140
- caps.parallelToolCalls === true,
137
+ // Strict tools keep parallel calls (measured on Azure, November 2026).
138
+ parallel_tool_calls: !schema && caps.parallelToolCalls === true,
141
139
  }
142
140
  : {}),
143
141
  }
@@ -5,7 +5,12 @@ import {
5
5
  modelReasoningSupportIssue,
6
6
  UnsupportedModelFeatureError,
7
7
  } from "@sixb/core/models"
8
- import { messagesInput } from "@sixb/model-protocols/messages"
8
+ import {
9
+ messagesInput,
10
+ messagesStrictTools,
11
+ StrictToolRefusals,
12
+ strictToolsKey,
13
+ } from "@sixb/model-protocols/messages"
9
14
  import { messagesOutputSchema } from "./messages-schema"
10
15
  import { prepareRequest } from "./request"
11
16
  import { object, PREFIX, positiveInteger } from "./util"
@@ -18,6 +23,15 @@ export interface MessagesRequestOptions {
18
23
  readonly thinkingMode?: "adaptive" | "manual"
19
24
  }
20
25
 
26
+ /** Strict tool sets Claude on Foundry refused: sent unconstrained from the start next time. */
27
+ export const strictToolRefusals = new StrictToolRefusals()
28
+
29
+ export interface FoundryMessagesRequest {
30
+ readonly body: JsonObject
31
+ /** The key of the strict tools it sends, if any, for {@link strictToolRefusals}. */
32
+ readonly strictTools?: string
33
+ }
34
+
21
35
  const RESERVED = new Set([
22
36
  "model",
23
37
  "messages",
@@ -58,12 +72,18 @@ export function validateMessagesOptions(options: MessagesRequestOptions): void {
58
72
  }
59
73
  }
60
74
 
75
+ /**
76
+ * `unconstrained`: no strict tools, as after Claude refused this request's. Otherwise a tool is
77
+ * strict when it asks, the deployment declares native structured output, and it fits Anthropic's
78
+ * limits, in order (`messagesStrictTools`).
79
+ */
61
80
  export function foundryMessagesRequest(
62
81
  request: LanguageModelRequest,
63
82
  definition: LanguageModelDefinition,
64
83
  options: MessagesRequestOptions,
65
- scope: string
66
- ): JsonObject {
84
+ scope: string,
85
+ unconstrained = false
86
+ ): FoundryMessagesRequest {
67
87
  const max = prepareRequest(request, definition, options, scope, true)
68
88
  let conversation = false
69
89
  for (const message of request.messages) {
@@ -101,7 +121,19 @@ export function foundryMessagesRequest(
101
121
  ...(thinking.effort === undefined ? {} : { effort: thinking.effort }),
102
122
  ...(schema ? { format: { type: "json_schema", schema } } : {}),
103
123
  }
104
- return {
124
+ const candidates = request.tools.map((tool) => ({
125
+ strict: tool.strict === true && caps.nativeStructuredOutput === true,
126
+ schema: messagesOutputSchema(tool.inputSchema),
127
+ }))
128
+ const chosen = messagesStrictTools(candidates, schema)
129
+ const constrained = request.tools.flatMap((tool, index) =>
130
+ chosen[index] ? [{ name: tool.name, input_schema: tool.inputSchema }] : []
131
+ )
132
+ const key = constrained.length === 0 ? undefined : strictToolsKey(constrained)
133
+ const refused = unconstrained || (key !== undefined && strictToolRefusals.has(key))
134
+ const strict = chosen.map((choice) => choice && !refused)
135
+ const strictTools = refused ? undefined : key
136
+ const body: JsonObject = {
105
137
  ...options.request,
106
138
  model: definition.modelId,
107
139
  messages: mapped.messages,
@@ -112,18 +144,17 @@ export function foundryMessagesRequest(
112
144
  ...(Object.keys(output).length ? { output_config: output } : {}),
113
145
  ...(request.tools.length
114
146
  ? {
115
- tools: request.tools.map((tool) => ({
147
+ tools: request.tools.map((tool, index) => ({
116
148
  name: tool.name,
117
149
  description: tool.description,
118
150
  input_schema: tool.inputSchema,
119
- ...(caps.nativeStructuredOutput === true && messagesOutputSchema(tool.inputSchema)
120
- ? { strict: true }
121
- : {}),
151
+ ...(strict[index] ? { strict: true } : {}),
122
152
  })),
123
153
  tool_choice: { type: "auto", disable_parallel_tool_use: caps.parallelToolCalls !== true },
124
154
  }
125
155
  : {}),
126
156
  }
157
+ return { body, ...(strictTools === undefined ? {} : { strictTools }) }
127
158
  }
128
159
 
129
160
  function reasoningRequest(
package/src/provider.ts CHANGED
@@ -17,7 +17,7 @@ import {
17
17
  UnsupportedModelFeatureError,
18
18
  } from "@sixb/core/models"
19
19
  import { chatEvents } from "@sixb/model-protocols/chat"
20
- import { messagesEvents } from "@sixb/model-protocols/messages"
20
+ import { isStrictToolLimitError, messagesEvents } from "@sixb/model-protocols/messages"
21
21
  import { responsesEvents } from "@sixb/model-protocols/responses"
22
22
  import { foundryEstimator, foundryUsage, type PricedEstimator } from "./accounting"
23
23
  import {
@@ -44,6 +44,7 @@ import { foundryMessagesEstimator, foundryMessagesUsage } from "./messages-accou
44
44
  import {
45
45
  foundryMessagesRequest,
46
46
  type MessagesRequestOptions,
47
+ strictToolRefusals,
47
48
  validateMessagesOptions,
48
49
  } from "./messages-request"
49
50
  import { type RequestOptions, responsesRequest, validateOptions } from "./request"
@@ -379,25 +380,26 @@ class FoundryModel<Protocol extends FoundryProtocol> implements AzureAIFoundryMo
379
380
  const model = await abortable(() => this.#pendingExecution!, request.signal)
380
381
  return model.stream(request)
381
382
  }
382
- const body =
383
+ const response =
383
384
  this.protocol === "messages"
384
- ? foundryMessagesRequest(request, this.definition, this.options, this.scope)
385
- : this.protocol === "chat"
386
- ? foundryChatRequest(request, this.definition, this.options, this.scope)
387
- : responsesRequest(
388
- request,
389
- this.definition,
390
- this.options,
391
- this.scope,
392
- this.resolution?.deployment
393
- )
394
- const response = await this.transport.post(
395
- JSON.stringify(body),
396
- request.signal,
397
- this.providerId,
398
- this.modelId,
399
- this.protocol
400
- )
385
+ ? await this.postMessages(request)
386
+ : await this.transport.post(
387
+ JSON.stringify(
388
+ this.protocol === "chat"
389
+ ? foundryChatRequest(request, this.definition, this.options, this.scope)
390
+ : responsesRequest(
391
+ request,
392
+ this.definition,
393
+ this.options,
394
+ this.scope,
395
+ this.resolution?.deployment
396
+ )
397
+ ),
398
+ request.signal,
399
+ this.providerId,
400
+ this.modelId,
401
+ this.protocol
402
+ )
401
403
  const id = this.transport.redactText(response, requestId(response))
402
404
  if (!response.body)
403
405
  throw new ModelProviderError(
@@ -449,6 +451,33 @@ class FoundryModel<Protocol extends FoundryProtocol> implements AzureAIFoundryMo
449
451
  }
450
452
  }
451
453
 
454
+ /** A limit no count predicts, such as the grammar's compiled size: once more, unconstrained. */
455
+ private async postMessages(request: LanguageModelRequest): Promise<Response> {
456
+ const prepared = foundryMessagesRequest(request, this.definition, this.options, this.scope)
457
+ const post = (body: JsonObject) =>
458
+ this.transport.post(
459
+ JSON.stringify(body),
460
+ request.signal,
461
+ this.providerId,
462
+ this.modelId,
463
+ "messages"
464
+ )
465
+ try {
466
+ return await post(prepared.body)
467
+ } catch (error) {
468
+ if (
469
+ prepared.strictTools === undefined ||
470
+ !(error instanceof ModelProviderError) ||
471
+ !isStrictToolLimitError(error)
472
+ )
473
+ throw error
474
+ strictToolRefusals.add(prepared.strictTools)
475
+ return post(
476
+ foundryMessagesRequest(request, this.definition, this.options, this.scope, true).body
477
+ )
478
+ }
479
+ }
480
+
452
481
  private async *events(
453
482
  source: AsyncIterable<LanguageModelStreamEvent>,
454
483
  response: Response
package/src/request.ts CHANGED
@@ -4,10 +4,11 @@ import {
4
4
  type LanguageModelDefinition,
5
5
  type LanguageModelRequest,
6
6
  type ModelMessage,
7
+ type ModelToolSpecification,
7
8
  modelReasoningSupportIssue,
8
9
  UnsupportedModelFeatureError,
9
10
  } from "@sixb/core/models"
10
- import { responsesInput } from "@sixb/model-protocols/responses"
11
+ import { requiredNullableSchema, responsesInput } from "@sixb/model-protocols/responses"
11
12
  import type { AzureAIFoundryDeployment } from "./discovery"
12
13
  import { foundryOutputSchema } from "./structured-output"
13
14
  import { object, PREFIX, positiveInteger } from "./util"
@@ -118,14 +119,16 @@ export function responsesRequest(
118
119
  throw new UnsupportedModelFeatureError(
119
120
  `${PREFIX} Reasoning summaries require a declared reasoning capability.`
120
121
  )
121
- const tools = request.tools.map((tool) => ({
122
- type: "function",
123
- name: tool.name,
124
- description: tool.description,
125
- parameters: tool.inputSchema,
126
- strict:
127
- caps.nativeStructuredOutput === true && foundryOutputSchema(tool.inputSchema) !== undefined,
128
- }))
122
+ const tools = request.tools.map((tool) => {
123
+ const schema = caps.nativeStructuredOutput === true ? foundryStrictTool(tool) : undefined
124
+ return {
125
+ type: "function",
126
+ name: tool.name,
127
+ description: tool.description,
128
+ parameters: schema ?? tool.inputSchema,
129
+ strict: schema !== undefined,
130
+ }
131
+ })
129
132
  return {
130
133
  ...options.request,
131
134
  model: definition.modelId,
@@ -138,8 +141,8 @@ export function responsesRequest(
138
141
  ? {
139
142
  tools,
140
143
  tool_choice: "auto",
141
- parallel_tool_calls:
142
- !schema && !tools.some((t) => t.strict) && caps.parallelToolCalls === true,
144
+ // Strict tools keep parallel calls (measured on Azure, November 2026).
145
+ parallel_tool_calls: !schema && caps.parallelToolCalls === true,
143
146
  }
144
147
  : {}),
145
148
  ...((reasoning !== undefined && reasoning !== "provider-default") || summary
@@ -264,3 +267,13 @@ function checkScope(data: unknown, scope: string): void {
264
267
  )
265
268
  }
266
269
  }
270
+
271
+ /**
272
+ * A tool that asked for strict arguments, in the form OpenAI's strict mode takes (every property
273
+ * required, an optional one nullable), when it fits Azure's strict subset.
274
+ */
275
+ export function foundryStrictTool(tool: ModelToolSpecification): JsonObject | undefined {
276
+ if (!tool.strict) return undefined
277
+ const schema = requiredNullableSchema(tool.inputSchema)
278
+ return foundryOutputSchema(schema) === undefined ? undefined : schema
279
+ }
@@ -13,6 +13,14 @@ const KEYWORDS = new Set([
13
13
  "$ref",
14
14
  "$defs",
15
15
  "definitions",
16
+ // Taken by strict mode on Azure's Responses and Chat APIs (measured November 2026); a strict
17
+ // `minimum` is enforced. `uniqueItems` is refused.
18
+ "minimum",
19
+ "maximum",
20
+ "minLength",
21
+ "maxLength",
22
+ "minItems",
23
+ "maxItems",
16
24
  ])
17
25
  const TYPES = new Set(["object", "array", "string", "number", "integer", "boolean", "null"])
18
26