Unified · Split
| @@ -183,7 +183,27 @@ func fixCLIToolResponse(input string) (string, error) { · 182 unmodified lines | |||
| 183 | var responseMap map[string]interface{} | 183 | var responseMap map[string]interface{} |
| 184 | errUnmarshal := json.Unmarshal([]byte(response.Raw), &responseMap) | 184 | errUnmarshal := json.Unmarshal([]byte(response.Raw), &responseMap) |
| 185 | if errUnmarshal != nil { | 185 | if errUnmarshal != nil { |
| 186 | log.Warnf("failed to unmarshal function response: %v\n", errUnmarshal) | 186 | log.Debugf("unmarshal function response failed, using fallback: %v", errUnmarshal) |
| 187 | funcResp := response.Get("functionResponse") | ||
| 188 | if funcResp.Exists() { | ||
| 189 | fr := map[string]interface{}{ | ||
| 190 | "name": funcResp.Get("name").String(), | ||
| 191 | "response": map[string]interface{}{ | ||
| 192 | "result": funcResp.Get("response").String(), | ||
| 193 | }, | ||
| 194 | } | ||
| 195 | if id := funcResp.Get("id").String(); id != "" { | ||
| 196 | fr["id"] = id | ||
| 197 | } | ||
| 198 | responseParts = append(responseParts, map[string]interface{}{"functionResponse": fr}) | ||
| 199 | continue | ||
| 200 | } | ||
| 201 | responseParts = append(responseParts, map[string]interface{}{ | ||
| 202 | "functionResponse": map[string]interface{}{ | ||
| 203 | "name": "unknown", | ||
| 204 | "response": map[string]interface{}{"result": response.String()}, | ||
| 205 | }, | ||
| 206 | }) | ||
| 187 | continue | 207 | continue |
| 188 | } | 208 | } |
| 189 | responseParts = append(responseParts, responseMap) | 209 | responseParts = append(responseParts, responseMap) |
| @@ -268,7 +288,27 @@ func fixCLIToolResponse(input string) (string, error) { · 78 unmodified lines | |||
| 268 | var responseMap map[string]interface{} | 288 | var responseMap map[string]interface{} |
| 269 | errUnmarshal := json.Unmarshal([]byte(response.Raw), &responseMap) | 289 | errUnmarshal := json.Unmarshal([]byte(response.Raw), &responseMap) |
| 270 | if errUnmarshal != nil { | 290 | if errUnmarshal != nil { |
| 271 | log.Warnf("failed to unmarshal function response: %v\n", errUnmarshal) | 291 | log.Debugf("unmarshal function response failed, using fallback: %v", errUnmarshal) |
| 292 | funcResp := response.Get("functionResponse") | ||
| 293 | if funcResp.Exists() { | ||
| 294 | fr := map[string]interface{}{ | ||
| 295 | "name": funcResp.Get("name").String(), | ||
| 296 | "response": map[string]interface{}{ | ||
| 297 | "result": funcResp.Get("response").String(), | ||
| 298 | }, | ||
| 299 | } | ||
| 300 | if id := funcResp.Get("id").String(); id != "" { | ||
| 301 | fr["id"] = id | ||
| 302 | } | ||
| 303 | responseParts = append(responseParts, map[string]interface{}{"functionResponse": fr}) | ||
| 304 | continue | ||
| 305 | } | ||
| 306 | responseParts = append(responseParts, map[string]interface{}{ | ||
| 307 | "functionResponse": map[string]interface{}{ | ||
| 308 | "name": "unknown", | ||
| 309 | "response": map[string]interface{}{"result": response.String()}, | ||
| 310 | }, | ||
| 311 | }) | ||
| 272 | continue | 312 | continue |
| 273 | } | 313 | } |
| 274 | responseParts = append(responseParts, responseMap) | 314 | responseParts = append(responseParts, responseMap) |