From 24655342a74a6d810964d310241318bc0fed0577 Mon Sep 17 00:00:00 2001 From: "CJACK." Date: Thu, 2 Apr 2026 20:11:29 +0800 Subject: [PATCH] fix: prefer quoted functionCall keys over bare matches --- internal/adapter/openai/tool_sieve_functioncall.go | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/internal/adapter/openai/tool_sieve_functioncall.go b/internal/adapter/openai/tool_sieve_functioncall.go index 35b0257..c629ace 100644 --- a/internal/adapter/openai/tool_sieve_functioncall.go +++ b/internal/adapter/openai/tool_sieve_functioncall.go @@ -7,16 +7,13 @@ func findQuotedFunctionCallKeyStart(s string) int { quotedIdx := findFunctionCallKeyStart(lower, `"functioncall"`) bareIdx := findFunctionCallKeyStart(lower, "functioncall") - if quotedIdx < 0 { - return bareIdx - } - if bareIdx < 0 { + // Prefer the quoted JSON key whenever we have a structural match. + // Bare-key detection is only for loose payloads where the quoted form + // is absent. + if quotedIdx >= 0 { return quotedIdx } - if bareIdx < quotedIdx { - return bareIdx - } - return quotedIdx + return bareIdx } func findFunctionCallKeyStart(lower, key string) int {