Merge pull request #9743 from silencezhoudev/main

fix: support object-type arguments in tool call parsing
This commit is contained in:
Dallin Romney 2026-01-23 10:20:40 -08:00 • committed by GitHub
commit 363c3c7e72
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -3,6 +3,17 @@ import { ToolCallDelta } from "..";
export function safeParseToolCallArgs(
toolCall: ToolCallDelta,
): Record<string, any> {
const args = toolCall.function?.arguments;
if (
args &&
typeof args === "object" &&
!Array.isArray(args) &&
Object.keys(args).length > 0
) {
return args;
}
try {
return JSON.parse(toolCall.function?.arguments?.trim() || "{}");
} catch (e) {