Merge pull request #6312 from continuedev/dallin/handle-empty-space-args

Handle empty string json args
This commit is contained in:
Dallin Romney 2025-06-27 18:18:33 -07:00 • committed by GitHub
commit fbcd6b25db
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 7 additions and 3 deletions

View file

@ -4,7 +4,7 @@ export function safeParseToolCallArgs(
toolCall: ToolCallDelta,
): Record<string, any> {
try {
return JSON.parse(toolCall.function?.arguments ?? "{}");
return JSON.parse(toolCall.function?.arguments?.trim() || "{}");
} catch (e) {
console.error(
`Failed to parse tool call arguments:\nTool call: ${toolCall.function?.name + " " + toolCall.id}\nArgs:${toolCall.function?.arguments}\n`,

View file

@ -10,7 +10,11 @@ const ResultGroup = memo(function ResultGroup({ group }: ResultGroupProps) {
return (
<>
{group.map((result, i) => (
<Result key={i} result={result} prevResult={group[i - 1]}></Result>
<Result
key={`${result.timestamp}-${i}`}
result={result}
prevResult={group[i - 1]}
></Result>
))}
</>
);

View file

@ -3,7 +3,7 @@ export function safeParseArgs(
errorId?: string,
): Record<string, any> {
try {
return JSON.parse(args ?? "{}");
return JSON.parse(args?.trim() || "{}");
} catch (e) {
const identifier = errorId ? `Call: ${errorId}\nArgs:${args}\n` : "";
console.error(