{"record":{"id":"14d00dc271039ad3","repo":"alibaba/spring-ai-alibaba","slug":"error-14d00d","errorCode":null,"errorMessage":"解析模型调用结果出错，请重试","messagePattern":"解析模型调用结果出错，请重试","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-start/src/main/java/com/alibaba/cloud/ai/studio/admin/service/impl/EvaluatorServiceImpl.java","lineNumber":190,"sourceCode":"\n        String userPrompt = modelConfigParser.replaceVariables(request.getPrompt(), request.getVariables());\n\n        String prompt = userPrompt.concat(SYSTEM_PROMPT);\n\n        log.info(\"evaluatorTest:prompt,{}\", prompt);\n\n        String response = Objects.requireNonNull(client.prompt(prompt).call().content()).trim();\n\n        log.info(\"模型返回值:{}\", response);\n\n        String formatedResponse = extractRawText(response);\n        log.info(\"模型返回值:{},格式化后模型返回值:{}.\", response, formatedResponse);\n\n        try {\n            return JSONObject.parseObject(formatedResponse, EvaluatorDebugResult.class);\n        } catch (Exception e) {\n            log.info(\"解析失败: {}\", formatedResponse, e);\n            throw new RuntimeException(\"解析模型调用结果出错，请重试\");\n        }\n\n    }\n\n} \n","sourceCodeStart":172,"sourceCodeEnd":196,"githubUrl":"https://github.com/alibaba/spring-ai-alibaba/blob/f82da0b50f35744c13968191be2b1cd2452ef550/spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-start/src/main/java/com/alibaba/cloud/ai/studio/admin/service/impl/EvaluatorServiceImpl.java#L172-L196","documentation":"Thrown by EvaluatorServiceImpl.evaluatorTest after the LLM responds: the model's output string cannot be parsed into EvaluatorDebugResult via fastjson JSONObject.parseObject. The error indicates the model returned something other than the expected JSON structure.","triggerScenarios":"The evaluator's model prompt yields free-form text, markdown fences (```json ... ```), trailing prose, or truncated JSON; formatedResponse still isn't valid JSON matching EvaluatorDebugResult fields.","commonSituations":"Weak/older models ignoring strict JSON output instructions; temperature too high; prompt template edited so the JSON schema example was lost; model returning Chinese text where the parser expects typed fields; max_tokens cutting JSON mid-object.","solutions":["Retry the debug call — the message itself says 'please retry' and LLM output is nondeterministic","Strip markdown code fences and extract the first {...} block before parseObject","Enable JSON mode / structured output on the model call and tighten the prompt to mandate exact JSON schema","Inspect the log line '解析失败: {}' to see the raw response and fix the prompt or parser accordingly","Wrap parseObject with a fallback parser or default EvaluatorDebugResult on failure"],"exampleFix":"// before\nreturn JSONObject.parseObject(formatedResponse, EvaluatorDebugResult.class);\n// after\nString json = extractJsonBlock(formatedResponse); // strip ``` fences / surrounding text\ntry {\n    return JSONObject.parseObject(json, EvaluatorDebugResult.class);\n} catch (Exception e) {\n    throw new EvaluatorResponseParseException(\"Model returned non-JSON output: \" + json, e);\n}","handlingStrategy":"retry","validationCode":"String json = extractJsonBlock(response);\nif (json == null || !json.trim().startsWith(\"{\")) throw new RetryableFormatException(response);","typeGuard":"boolean looksLikeJson(String s) { return s != null && s.replace(\"```\",\"\").trim().startsWith(\"{\"); }","tryCatchPattern":"try { return JSONObject.parseObject(formatedResponse, EvaluatorDebugResult.class); } catch (Exception e) { log.warn(\"non-JSON model output: {}\", formatedResponse); return retryWithStrictJsonPrompt(); }","preventionTips":["Enable JSON/structured output mode on the model","Include an explicit JSON schema example in the prompt","Strip markdown fences before parsing","Log raw responses for debugging"],"tags":["json","llm","parsing"],"backgroundTag":"json-parse-error","analyzedSha":"f82da0b50f35744c13968191be2b1cd2452ef550","analyzedAt":"2026-09-09T15:32:42.421Z","contentChangedAt":"2026-09-09T15:32:42.421Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}