fix: preserve tool_use on malformed tool arguments to keep tool_result pairing valid

This commit is contained in:
Seefs
2026-03-02 15:41:03 +08:00
parent 4d6f9a94a3
commit da11617776
2 changed files with 46 additions and 2 deletions

View File

@@ -376,9 +376,9 @@ func RequestOpenAI2ClaudeMessage(c *gin.Context, textRequest dto.GeneralOpenAIRe
if message.ToolCalls != nil {
for _, toolCall := range message.ParseToolCalls() {
inputObj := make(map[string]any)
if err := json.Unmarshal([]byte(toolCall.Function.Arguments), &inputObj); err != nil {
if err := common.UnmarshalJsonStr(toolCall.Function.Arguments, &inputObj); err != nil {
common.SysLog("tool call function arguments is not a map[string]any: " + fmt.Sprintf("%v", toolCall.Function.Arguments))
continue
inputObj = map[string]any{}
}
claudeMediaMessages = append(claudeMediaMessages, dto.ClaudeMediaMessage{
Type: "tool_use",