Skip to content

Commit 950d89d

Browse files
committed
refactor(ai): decode toolkit-free tool params and results as unknown
1 parent b2e21fd commit 950d89d

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

‎.changeset/ai-response-parts-without-toolkit.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
"effect": patch
33
---
44

5-
Allow `Response.AllParts`, `Response.Part` and `Response.StreamPart` to be called without a toolkit, decoding tool call and tool result parts for any tool name with JSON parameters and results.
5+
Allow `Response.AllParts`, `Response.Part` and `Response.StreamPart` to be called without a toolkit, decoding tool call and tool result parts for any tool name with `unknown` parameters and results.

‎packages/effect/src/ai/Response.ts‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -170,15 +170,15 @@ const toolPartSchemas = (tool: Tool.Any) => {
170170
return parts
171171
}
172172

173-
type AnyToolParts = ToolCallPart<string, Schema.Json> | ToolResultPart<string, Schema.Json, Schema.Json>
173+
type AnyToolParts = ToolCallPart<string, unknown> | ToolResultPart<string, unknown, unknown>
174174

175175
const toolPartSchemasFor = (
176176
toolkit: Toolkit.Any | Toolkit.WithHandler<any> | undefined
177177
): ReadonlyArray<Schema.Top> => {
178178
if (toolkit === undefined) {
179179
return [
180-
makeToolCallPart(Schema.String, Schema.Json),
181-
makeToolResultPart(Schema.String, Schema.Json, Schema.Json)
180+
makeToolCallPart(Schema.String, Schema.Unknown),
181+
makeToolResultPart(Schema.String, Schema.Unknown, Schema.Unknown)
182182
]
183183
}
184184
const parts = Object.values(toolkit.tools as Record<string, Tool.Any>).map(toolPartSchemas)
@@ -194,7 +194,7 @@ const toolPartSchemasFor = (
194194
* and tool result parts dynamically created based on the provided toolkit.
195195
*
196196
* When no toolkit is provided, tool call and tool result parts accept any tool
197-
* name, with parameters and results decoded as JSON.
197+
* name, with parameters and results decoded as `unknown`.
198198
*
199199
* **Example** (Building a response parts schema)
200200
*
@@ -305,7 +305,7 @@ export type PartEncoded =
305305
* **Details**
306306
*
307307
* When no toolkit is provided, tool call and tool result parts accept any tool
308-
* name, with parameters and results decoded as JSON.
308+
* name, with parameters and results decoded as `unknown`.
309309
*
310310
* @stability unstable
311311
* @category schemas
@@ -399,7 +399,7 @@ export type StreamPartEncoded =
399399
* **Details**
400400
*
401401
* When no toolkit is provided, tool call and tool result parts accept any tool
402-
* name, with parameters and results decoded as JSON.
402+
* name, with parameters and results decoded as `unknown`.
403403
*
404404
* @stability unstable
405405
* @category schemas

0 commit comments

Comments
 (0)