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, }); }