Skip to content

Commit 19c4fcf

Browse files
corners99claude
andauthored
fix(ag-ui): use input instead of args for tool-call parts in message conversion (#1149)
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 <noreply@anthropic.com>
1 parent a1b68cc commit 19c4fcf

2 files changed

Lines changed: 15 additions & 3 deletions

File tree

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
"@voltagent/ag-ui": patch
3+
---
4+
5+
fix: use `input` instead of `args` for tool-call parts in message conversion
6+
7+
When converting CopilotKit assistant messages with tool calls to VoltAgent format,
8+
the adapter was setting `args` on tool-call parts. The AI SDK's `ToolCallPart`
9+
interface expects `input`, causing the Anthropic provider to send `undefined` as
10+
the tool_use input — rejected by the API with:
11+
12+
"messages.N.content.N.tool_use.input: Input should be a valid dictionary"

packages/ag-ui/src/voltagent-agent.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ const isToolMessage = (message: Message): message is ToolMessage => message.role
276276

277277
type VoltUIPart =
278278
| { type: "text"; text: string }
279-
| { type: "tool-call"; toolCallId: string; toolName: string; args?: unknown }
279+
| { type: "tool-call"; toolCallId: string; toolName: string; input?: unknown }
280280
| { type: "tool-result"; toolCallId?: string; toolName?: string; output?: unknown };
281281

282282
type VoltUIMessage = {
@@ -311,13 +311,13 @@ function convertAGUIMessagesToVoltMessages(messages: Message[]): VoltUIMessage[]
311311
}
312312

313313
for (const call of msg.toolCalls ?? []) {
314-
const args = safelyParseJson(call.function.arguments);
314+
const input = safelyParseJson(call.function.arguments);
315315
toolNameById.set(call.id, call.function.name);
316316
parts.push({
317317
type: "tool-call",
318318
toolCallId: call.id,
319319
toolName: call.function.name,
320-
args,
320+
input,
321321
});
322322
}
323323

0 commit comments

Comments
 (0)