@ai-sdk/xai 3.0.131 → 3.0.133

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/xai",
3
- "version": "3.0.131",
3
+ "version": "3.0.133",
4
4
  "license": "Apache-2.0",
5
5
  "sideEffects": false,
6
6
  "main": "./dist/index.js",
@@ -30,8 +30,8 @@
30
30
  },
31
31
  "dependencies": {
32
32
  "@ai-sdk/openai-compatible": "2.0.75",
33
- "@ai-sdk/provider-utils": "4.0.51",
34
- "@ai-sdk/provider": "3.0.16"
33
+ "@ai-sdk/provider": "3.0.16",
34
+ "@ai-sdk/provider-utils": "4.0.51"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@types/node": "20.17.24",
@@ -4,7 +4,6 @@ import {
4
4
  type SharedV3Warning,
5
5
  } from '@ai-sdk/provider';
6
6
  import { validateTypes } from '@ai-sdk/provider-utils';
7
- import { removeAdditionalPropertiesFalse } from '../remove-additional-properties';
8
7
  import { fileSearchArgsSchema } from '../tool/file-search';
9
8
  import { mcpServerArgsSchema } from '../tool/mcp-server';
10
9
  import { webSearchArgsSchema } from '../tool/web-search';
@@ -144,7 +143,7 @@ export async function prepareResponsesTools({
144
143
  type: 'function',
145
144
  name: tool.name,
146
145
  description: tool.description,
147
- parameters: removeAdditionalPropertiesFalse(tool.inputSchema),
146
+ parameters: tool.inputSchema,
148
147
  ...(tool.strict != null ? { strict: tool.strict } : {}),
149
148
  });
150
149
  }
@@ -544,7 +544,7 @@ export class XaiChatLanguageModel implements LanguageModelV3 {
544
544
  }
545
545
 
546
546
  // process tool calls
547
- if (delta.tool_calls != null) {
547
+ if (delta.tool_calls != null && delta.tool_calls.length > 0) {
548
548
  // end active reasoning block before tool calls start
549
549
  if (
550
550
  activeReasoningBlockId != null &&
@@ -3,7 +3,6 @@ import {
3
3
  type LanguageModelV3CallOptions,
4
4
  type SharedV3Warning,
5
5
  } from '@ai-sdk/provider';
6
- import { removeAdditionalPropertiesFalse } from './remove-additional-properties';
7
6
  import type { XaiToolChoice } from './xai-chat-prompt';
8
7
 
9
8
  export function prepareTools({
@@ -59,7 +58,7 @@ export function prepareTools({
59
58
  function: {
60
59
  name: tool.name,
61
60
  description: tool.description,
62
- parameters: removeAdditionalPropertiesFalse(tool.inputSchema),
61
+ parameters: tool.inputSchema,
63
62
  ...(tool.strict != null ? { strict: tool.strict } : {}),
64
63
  },
65
64
  });
@@ -1,24 +0,0 @@
1
- /**
2
- * Recursively removes `additionalProperties: false` entries from a JSON
3
- * schema.
4
- * Used to sanitize tool input schemas before sending them to the xAI API.
5
- * https://docs.x.ai/developers/model-capabilities/text/structured-outputs#supported-types
6
- */
7
- export function removeAdditionalPropertiesFalse(value: unknown): unknown {
8
- if (Array.isArray(value)) {
9
- return value.map(removeAdditionalPropertiesFalse);
10
- }
11
-
12
- if (value == null || typeof value !== 'object') {
13
- return value;
14
- }
15
-
16
- const result: Record<string, unknown> = {};
17
- for (const [key, propertyValue] of Object.entries(value)) {
18
- if (key === 'additionalProperties' && propertyValue === false) {
19
- continue;
20
- }
21
- result[key] = removeAdditionalPropertiesFalse(propertyValue);
22
- }
23
- return result;
24
- }