From 27387c63dca76c6bd2996dc9eb528333ad5d8898 Mon Sep 17 00:00:00 2001 From: Michael Klevansky Date: Thu, 12 Mar 2026 13:58:20 +1100 Subject: [PATCH] fix(ag-ui): use `input` instead of `args` for tool-call parts in message conversion MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When converting CopilotKit assistant messages with tool calls to VoltAgent format, the adapter sets `args` on tool-call parts. The AI SDK's `ToolCallPart` interface expects `input`, so the Anthropic provider sends `undefined` as the tool_use input — rejected by the API with: "messages.N.content.N.tool_use.input: Input should be a valid dictionary" This rename aligns with the AI SDK's ToolCallPart interface from @ai-sdk/provider-utils. Co-Authored-By: Claude Opus 4.6 --- .changeset/fix-ag-ui-tool-call-input.md | 12 ++++++++++++ packages/ag-ui/src/voltagent-agent.ts | 6 +++--- 2 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 .changeset/fix-ag-ui-tool-call-input.md diff --git a/.changeset/fix-ag-ui-tool-call-input.md b/.changeset/fix-ag-ui-tool-call-input.md new file mode 100644 index 000000000..1155e82b1 --- /dev/null +++ b/.changeset/fix-ag-ui-tool-call-input.md @@ -0,0 +1,12 @@ +--- +"@voltagent/ag-ui": patch +--- + +fix: use `input` instead of `args` for tool-call parts in message conversion + +When converting CopilotKit assistant messages with tool calls to VoltAgent format, +the adapter was setting `args` on tool-call parts. The AI SDK's `ToolCallPart` +interface expects `input`, causing the Anthropic provider to send `undefined` as +the tool_use input — rejected by the API with: + + "messages.N.content.N.tool_use.input: Input should be a valid dictionary" diff --git a/packages/ag-ui/src/voltagent-agent.ts b/packages/ag-ui/src/voltagent-agent.ts index 794d4da34..d9919aa42 100644 --- a/packages/ag-ui/src/voltagent-agent.ts +++ b/packages/ag-ui/src/voltagent-agent.ts @@ -276,7 +276,7 @@ const isToolMessage = (message: Message): message is ToolMessage => message.role type VoltUIPart = | { type: "text"; text: string } - | { type: "tool-call"; toolCallId: string; toolName: string; args?: unknown } + | { type: "tool-call"; toolCallId: string; toolName: string; input?: unknown } | { type: "tool-result"; toolCallId?: string; toolName?: string; output?: unknown }; type VoltUIMessage = { @@ -311,13 +311,13 @@ function convertAGUIMessagesToVoltMessages(messages: Message[]): VoltUIMessage[] } for (const call of msg.toolCalls ?? []) { - const args = safelyParseJson(call.function.arguments); + const input = safelyParseJson(call.function.arguments); toolNameById.set(call.id, call.function.name); parts.push({ type: "tool-call", toolCallId: call.id, toolName: call.function.name, - args, + input, }); }