Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/lemon-roses-yawn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@ai-sdk/provider': patch
---

fix(spec): `LanguageModelV3ToolResult["result"]` is now `JSONObject | JSONArray`
10 changes: 8 additions & 2 deletions packages/openai/src/responses/openai-responses-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,10 @@ export const openaiResponsesChunkSchema = lazySchema(() =>
results: z
.array(
z.object({
attributes: z.record(z.string(), z.unknown()),
attributes: z.record(
z.string(),
z.union([z.string(), z.number(), z.boolean()]),
),
Comment on lines +406 to +409
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as a side note: JSON API / JSON Schema specs do not have an "unknown" type. I haven't checked all providers we support yet, but all the important ones do have a JSON API spec for their APIs.

We still use .unknown() in other places related to provider requests/responses that we could probably all get rid off with some research.

file_id: z.string(),
filename: z.string(),
score: z.number(),
Expand Down Expand Up @@ -614,7 +617,10 @@ export const openaiResponsesResponseSchema = lazySchema(() =>
results: z
.array(
z.object({
attributes: z.record(z.string(), z.unknown()),
attributes: z.record(
z.string(),
z.union([z.string(), z.number(), z.boolean()]),
),
file_id: z.string(),
filename: z.string(),
score: z.number(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { JSONArray, JSONObject } from '../../json-value';
import { SharedV3ProviderMetadata } from '../../shared/v3/shared-v3-provider-metadata';

/**
Expand All @@ -19,7 +20,7 @@ export type LanguageModelV3ToolResult = {
/**
* Result of the tool call. This is a JSON-serializable object.
*/
result: unknown;
result: JSONObject | JSONArray;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will change to NonNullable<JSONValue> after discussing with @lgrammel


/**
* Optional flag if the result is an error or an error message.
Expand Down
Loading