Skip to content

Commit bb36798

Browse files
authored
fix(spec): LanguageModelV3ToolResult["result"] change from unknown to NonNullable<JSONValue> (#9931)
## Background Discovered in #9896 (review) ## Summary As far as I can tell, `result` has to be set to something that is not null or undefined. This makes the spec more precise and would have surfaced the problem of #9896 (review) immediately ## Manual Verification When the fix from this PR is applied, a type error is thrown in #9896
1 parent 4eabbc5 commit bb36798

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

.changeset/lemon-roses-yawn.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@ai-sdk/provider': patch
3+
---
4+
5+
fix(spec): `LanguageModelV3ToolResult["result"]` change from `unknown` to `NonNullable<JSONValue>`

packages/openai/src/responses/openai-responses-api.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,10 @@ export const openaiResponsesChunkSchema = lazySchema(() =>
403403
results: z
404404
.array(
405405
z.object({
406-
attributes: z.record(z.string(), z.unknown()),
406+
attributes: z.record(
407+
z.string(),
408+
z.union([z.string(), z.number(), z.boolean()]),
409+
),
407410
file_id: z.string(),
408411
filename: z.string(),
409412
score: z.number(),
@@ -624,7 +627,10 @@ export const openaiResponsesResponseSchema = lazySchema(() =>
624627
results: z
625628
.array(
626629
z.object({
627-
attributes: z.record(z.string(), z.unknown()),
630+
attributes: z.record(
631+
z.string(),
632+
z.union([z.string(), z.number(), z.boolean()]),
633+
),
628634
file_id: z.string(),
629635
filename: z.string(),
630636
score: z.number(),

packages/provider/src/language-model/v3/language-model-v3-tool-result.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { JSONValue } from '../../json-value';
12
import { SharedV3ProviderMetadata } from '../../shared/v3/shared-v3-provider-metadata';
23

34
/**
@@ -19,7 +20,7 @@ export type LanguageModelV3ToolResult = {
1920
/**
2021
* Result of the tool call. This is a JSON-serializable object.
2122
*/
22-
result: NonNullable<unknown>;
23+
result: NonNullable<JSONValue>;
2324

2425
/**
2526
* Optional flag if the result is an error or an error message.

0 commit comments

Comments
 (0)