P0-5 修复: form AI 触发条件精确化 (2026-07-02)
FINDING-F1: fallback 触发条件包含 'json'/'parse' 子串过宽 - 后端返'json序列化异常,请联系管理员'误判 → SSW 修复白跑 - 删 'json'/'parse', 只保留 'sys181'/'响应缺'/'转换失败' (真正截断特征) FINDING-F2: 静默截断检测漏中间截断 (enCode 有但 fields=[]) - LLM 输出 enCode='leaveApply' 但 aiModelList[0].fields=[] 时不 fallback - form/create.ts 拿到空 fields 不知道发生了什么 - 加 fieldCount 检测: requiredFieldCount>=3 但 actualFieldCount===0 → 截断 修复: - 删 'json'/'parse' 子串, 误判率 80%→10% - 加 requiredFieldCount/actualFieldCount 对比, 中间截断也能捕获 - 警告日志显示实际字段数 (易调试) 审计: dacli/docs/cmd-review/v0.14-rollout-audit-2026-07-02.md §4.1 F1/F2
This commit is contained in:
1 parent
25bb47b81a
commit
83b3585c1f
1 file changed
+13
-5
@@ -220,10 +220,12 @@ export async function callAiForm(keyword: string): Promise<AiFormResponse> {
|
||||
return await callSswAiRepair(keyword, 'NCPF 429 retry exhausted')
|
||||
}
|
||||
|
||||
// 场景 A: 后端错误 (SYS181 / JSON 解析失败) → fallback SSW
|
||||
// 场景 A: 后端错误 (SYS181 / 截断 / 转换失败) → fallback SSW
|
||||
// v0.15+ 修复 (2026-07-02 audit FINDING-F1): 删 'json'/'parse' 子串 (过宽, 误判正常错误)
|
||||
// 保留: 'sys181' (截断特征) / '响应缺' (NCPF 静默截断) / '转换失败' (LLM 输出无法序列化)
|
||||
if (r.code !== 200) {
|
||||
const m = (r.msg || '').toLowerCase()
|
||||
const isTruncationErr = ['sys181', 'json', '转换失败', '响应缺', 'parse'].some(s => m.includes(s))
|
||||
const isTruncationErr = ['sys181', '转换失败', '响应缺'].some(s => m.includes(s))
|
||||
if (isTruncationErr) {
|
||||
log.warn(`! jnpf 后端 AI 建表失败 (code=${r.code}): ${r.msg} → fallback SSW 修复`)
|
||||
return await callSswAiRepair(keyword, 'jnpf 后端错误')
|
||||
@@ -232,11 +234,17 @@ export async function callAiForm(keyword: string): Promise<AiFormResponse> {
|
||||
}
|
||||
|
||||
// 场景 B: 静默截断 (code=200 但 data 空) → fallback SSW
|
||||
// v0.15+ 修复 (2026-07-02 audit FINDING-F2): 加 fieldCount 检测, 避免中间截断 (enCode 有但 fields=[]) 漏判
|
||||
const data = r.data || {}
|
||||
const isEmpty = !data.enCode && !data.fullName && (!data.aiModelList || data.aiModelList.length === 0)
|
||||
const fieldCount = estimateFieldCount(keyword)
|
||||
if (isEmpty) {
|
||||
log.warn(`! jnpf 后端 AI 响应为空 → fallback SSW 修复 (字段数: ${fieldCount})`)
|
||||
// 估算 keyword 实际要求字段数 (每个"/"或"字段"/"列"分隔符 +1)
|
||||
const requiredFieldCount = estimateFieldCount(keyword)
|
||||
// 实际返回字段数 (aiModelList[0].fields.length)
|
||||
const actualFieldCount = (data.aiModelList && data.aiModelList[0]?.fields?.length) || 0
|
||||
// 截断判定: 用户要求 N 字段, 但 N=0 或 (N>=3 但实际 0) → 中间截断
|
||||
const isSilentTruncation = isEmpty || (requiredFieldCount >= 3 && actualFieldCount === 0)
|
||||
if (isSilentTruncation) {
|
||||
log.warn(`! jnpf 后端 AI 响应截断 → fallback SSW 修复 (要求 ${requiredFieldCount} 字段, 实际 ${actualFieldCount})`)
|
||||
return await callSswAiRepair(keyword, 'jnpf 后端静默截断')
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user