You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Parse stringified tool-call input before Zod validation
AI SDK can emit tool-call chunks with `input` as a raw JSON string when
its repair pass can't produce a parsed object, making Zod fail with a
confusing "expected object, received string". Parse the string in the
stream parser, and emit a clearer error if parsing fails.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: packages/agent-runtime/src/tools/tool-executor.ts
+20Lines changed: 20 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -51,6 +51,18 @@ export type ToolCallError = {
51
51
error: string
52
52
}&Pick<CodebuffToolCall,'toolCallId'>
53
53
54
+
functionstringInputError(
55
+
toolName: string,
56
+
toolCallId: string,
57
+
): ToolCallError{
58
+
return{
59
+
toolName,
60
+
toolCallId,
61
+
input: {},
62
+
error: `Invalid parameters for ${toolName}: tool arguments were a string, not a JSON object. This usually means the model emitted malformed JSON (e.g. unescaped newlines or quotes inside a string value). Re-issue the tool call with properly escaped JSON.`,
0 commit comments