From 283e5aa75274ff5fa2923d0bd5cda05bfa788366 Mon Sep 17 00:00:00 2001 From: Alexandre Bezroutchko Date: Fri, 27 Jun 2025 10:06:43 +0200 Subject: [PATCH] Fix function call extraction to use most recent occurrence Changed find() to findLast() in extractFunctionCallByName function to get the most recent function call occurrence instead of the first one. --- src/app/hooks/useHandleSessionHistory.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/hooks/useHandleSessionHistory.ts b/src/app/hooks/useHandleSessionHistory.ts index f256cf719..0c775f445 100644 --- a/src/app/hooks/useHandleSessionHistory.ts +++ b/src/app/hooks/useHandleSessionHistory.ts @@ -33,7 +33,7 @@ export function useHandleSessionHistory() { const extractFunctionCallByName = (name: string, content: any[] = []): any => { if (!Array.isArray(content)) return undefined; - return content.find((c: any) => c.type === 'function_call' && c.name === name); + return content.findLast((c: any) => c.type === 'function_call' && c.name === name); }; const maybeParseJson = (val: any) => {