@sixb/azure-ai-foundry 0.1.6 → 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.
- package/dist/chat-request.d.ts.map +1 -1
- package/dist/diagnostics.d.ts.map +1 -1
- package/dist/index.js +79 -32
- package/dist/index.js.map +9 -9
- package/dist/messages-request.d.ts +14 -1
- package/dist/messages-request.d.ts.map +1 -1
- package/dist/provider.d.ts.map +1 -1
- package/dist/request.d.ts +6 -1
- package/dist/request.d.ts.map +1 -1
- package/dist/structured-output.d.ts.map +1 -1
- package/dist/transport.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/chat-request.ts +18 -20
- package/src/diagnostics.ts +1 -0
- package/src/messages-request.ts +39 -8
- package/src/provider.ts +48 -19
- package/src/request.ts +24 -11
- package/src/structured-output.ts +8 -0
- package/src/transport.ts +2 -0
|
@@ -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
|
-
|
|
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;
|
|
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;AAC1B,OAAO,EAGL,kBAAkB,EAEnB,MAAM,gCAAgC,CAAA;AAKvC,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAA;IACjC,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAA;IACnC,QAAQ,CAAC,OAAO,CAAC,EAAE,UAAU,CAAA;IAC7B,6EAA6E;IAC7E,QAAQ,CAAC,YAAY,CAAC,EAAE,UAAU,GAAG,QAAQ,CAAA;CAC9C;AAED,+FAA+F;AAC/F,eAAO,MAAM,kBAAkB,oBAA2B,CAAA;AAE1D,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAA;IACzB,oFAAoF;IACpF,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAC9B;AAmBD,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,sBAAsB,GAAG,IAAI,CAqB7E;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,oBAAoB,EAC7B,UAAU,EAAE,uBAAuB,EACnC,OAAO,EAAE,sBAAsB,EAC/B,KAAK,EAAE,MAAM,EACb,aAAa,UAAQ,GACpB,sBAAsB,CAwExB"}
|
package/dist/provider.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,aAAa,EAClB,KAAK,uBAAuB,EAC5B,KAAK,kBAAkB,EACvB,KAAK,qBAAqB,EAM1B,KAAK,kBAAkB,EAEvB,KAAK,aAAa,EAClB,KAAK,mBAAmB,EAEzB,MAAM,mBAAmB,CAAA;AAK1B,OAAO,EACL,KAAK,4BAA4B,EAGlC,MAAM,WAAW,CAAA;AAElB,OAAO,EAAE,KAAK,kBAAkB,EAA2C,MAAM,gBAAgB,CAAA;AACjG,OAAO,EACL,KAAK,qBAAqB,EAC1B,KAAK,wBAAwB,EAC7B,KAAK,8BAA8B,EAGpC,MAAM,aAAa,CAAA;AACpB,OAAO,EACL,KAAK,4BAA4B,EACjC,KAAK,8BAA8B,EACnC,KAAK,uCAAuC,EAE7C,MAAM,aAAa,CAAA;AAEpB,OAAO,EAEL,KAAK,sBAAsB,
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,aAAa,EAClB,KAAK,uBAAuB,EAC5B,KAAK,kBAAkB,EACvB,KAAK,qBAAqB,EAM1B,KAAK,kBAAkB,EAEvB,KAAK,aAAa,EAClB,KAAK,mBAAmB,EAEzB,MAAM,mBAAmB,CAAA;AAK1B,OAAO,EACL,KAAK,4BAA4B,EAGlC,MAAM,WAAW,CAAA;AAElB,OAAO,EAAE,KAAK,kBAA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C,QAAQ,EAAE,QAAQ,CAAA;IAC3B,QAAQ,CAAC,QAAQ,EAAE,2BAA2B,CAAA;IAC9C,QAAQ,CAAC,aAAa,EAAE,kBAAkB,CAAA;IAC1C,OAAO,CAAC,OAAO,CAAC,EAAE;QAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAC,CAAA;CAC1F;AAED,MAAM,WAAW,sBAAuB,SAAQ,qBAAqB;IACnE,CAAC,cAAc,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,0BAA0B,GAAG,mBAAmB,CAAA;IACnF,SAAS,CACP,cAAc,EAAE,MAAM,EACtB,OAAO,CAAC,EAAE,0BAA0B,GACnC,mBAAmB,CAAC,WAAW,CAAC,CAAA;IACnC,QAAQ,CACN,cAAc,EAAE,MAAM,EACtB,OAAO,CAAC,EAAE,6BAA6B,GACtC,mBAAmB,CAAC,UAAU,CAAC,CAAA;IAClC,SAAS,CACP,cAAc,EAAE,MAAM,EACtB,OAAO,EAAE,8BAA8B,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
|
package/dist/request.d.ts.map
CHANGED
|
@@ -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,
|
|
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,EACjB,KAAK,sBAAsB,EAG5B,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,QAAQ,CAAC,OAAO,CAAC,EAAE,UAAU,CAAA;IAC7B,iGAAiG;IACjG,QAAQ,CAAC,gBAAgB,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,SAAS,GAAG,UAAU,CAAA;IACnE,2FAA2F;IAC3F,QAAQ,CAAC,kBAAkB,CAAC,EAAE,OAAO,CAAA;IACrC,oEAAoE;IACpE,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAA;CACpC;AAyBD,wBAAgB,eAAe,CAAC,OAAO,EAAE,cAAc,GAAG,IAAI,CAe7D;AAED,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,oBAAoB,EAC7B,UAAU,EAAE,uBAAuB,EACnC,OAAO,EAAE,cAAc,EACvB,KAAK,EAAE,MAAM,EACb,UAAU,CAAC,EAAE,wBAAwB,GACpC,UAAU,CAqGZ;AAED,wBAAgB,cAAc,CAC5B,OAAO,EAAE,oBAAoB,EAC7B,UAAU,EAAE,uBAAuB,EACnC,OAAO,EAAE;IAAE,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAA;CAAE,EACnF,KAAK,EAAE,MAAM,EACb,SAAS,UAAQ,GAChB,MAAM,GAAG,SAAS,CAepB;AAED,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,SAAS,YAAY,EAAE,EACjC,UAAU,EAAE,uBAAuB,EACnC,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,SAAS,UAAQ,GAChB,IAAI,CAwDN;AAUD;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,sBAAsB,GAAG,UAAU,GAAG,SAAS,CAItF"}
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
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/dist/transport.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../src/transport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../src/transport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAEtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAA;AAGlD,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,WAAW,KAAK,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,CAAA;AAC1E,MAAM,MAAM,eAAe,GAAG,WAAW,GAAG,UAAU,GAAG,MAAM,CAAA;AAE/D,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC,MAAM,GAAG,SAAS,CAAC,CAAA;IAChD,QAAQ,CAAC,OAAO,CAAC,EAAE,WAAW,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,CAAA;IAChE,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG,GAAG,OAAO,EAAE,IAAI,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAA;IACzF,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAA;IAC5B,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAA;CAClC;AAED,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,QAAQ,CAAC,WAAW,CAA8C;IAC1E,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,UAAU,EAAE,MA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.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.
|
|
35
|
-
"@sixb/model-protocols": "0.
|
|
34
|
+
"@sixb/core": "^0.2.4",
|
|
35
|
+
"@sixb/model-protocols": "0.2.4"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@types/bun": "latest",
|
package/src/chat-request.ts
CHANGED
|
@@ -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
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
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
|
-
|
|
138
|
-
|
|
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
|
}
|
package/src/diagnostics.ts
CHANGED
|
@@ -21,6 +21,7 @@ export class RequestDiagnostics {
|
|
|
21
21
|
retryAfterMs: error.retryAfterMs,
|
|
22
22
|
code: error.code === undefined ? undefined : this.text(error.code),
|
|
23
23
|
requestId: error.requestId === undefined ? undefined : this.text(error.requestId),
|
|
24
|
+
reason: error.reason,
|
|
24
25
|
})
|
|
25
26
|
}
|
|
26
27
|
|
package/src/messages-request.ts
CHANGED
|
@@ -5,7 +5,12 @@ import {
|
|
|
5
5
|
modelReasoningSupportIssue,
|
|
6
6
|
UnsupportedModelFeatureError,
|
|
7
7
|
} from "@sixb/core/models"
|
|
8
|
-
import {
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
...(
|
|
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
|
|
383
|
+
const response =
|
|
383
384
|
this.protocol === "messages"
|
|
384
|
-
?
|
|
385
|
-
: this.
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
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
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
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
|
-
|
|
142
|
-
|
|
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
|
+
}
|
package/src/structured-output.ts
CHANGED
|
@@ -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
|
|
package/src/transport.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ModelProviderError } from "@sixb/core/models"
|
|
2
|
+
import { contextWindowRejection } from "@sixb/model-protocols/responses"
|
|
2
3
|
import { RequestDiagnostics } from "./diagnostics"
|
|
3
4
|
import { object, PREFIX, positiveInteger } from "./util"
|
|
4
5
|
|
|
@@ -257,6 +258,7 @@ async function httpError(
|
|
|
257
258
|
status: response.status,
|
|
258
259
|
requestId: requestId(response),
|
|
259
260
|
code,
|
|
261
|
+
...contextWindowRejection({ status: response.status, code, message }),
|
|
260
262
|
retryable: response.status === 408 || response.status === 429 || response.status >= 500,
|
|
261
263
|
...(ms !== undefined && Number.isFinite(ms) && ms >= 0 ? { retryAfterMs: Math.ceil(ms) } : {}),
|
|
262
264
|
})
|