Skip to content

Commit 363c3c7

Browse files
authored
Merge pull request #9743 from silencezhoudev/main
fix: support object-type arguments in tool call parsing
2 parents 46dc45a + 82f6f69 commit 363c3c7

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

core/tools/parseArgs.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,17 @@ import { ToolCallDelta } from "..";
33
export function safeParseToolCallArgs(
44
toolCall: ToolCallDelta,
55
): Record<string, any> {
6+
const args = toolCall.function?.arguments;
7+
8+
if (
9+
args &&
10+
typeof args === "object" &&
11+
!Array.isArray(args) &&
12+
Object.keys(args).length > 0
13+
) {
14+
return args;
15+
}
16+
617
try {
718
return JSON.parse(toolCall.function?.arguments?.trim() || "{}");
819
} catch (e) {

0 commit comments

Comments
 (0)