{"record":{"id":"95f763c26afa8199","repo":"gitbutlerapp/gitbutler","slug":"the-model-returned-no-reasoning-for","errorCode":null,"errorMessage":"The model returned no reasoning for \"{}\"","messagePattern":"The model returned no reasoning for \"(.+?)\"","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but-api/src/resolve/mod.rs","lineNumber":640,"sourceCode":"            );\n        };\n        if resolved_files[index].is_some() {\n            bail!(\n                \"The model returned more than one resolution for \\\"{}\\\"\",\n                resolution.path\n            );\n        }\n        let file = &request.files[index];\n        if resolution.hunks.len() != file.hunks.len() {\n            bail!(\n                \"The model returned {} resolved hunks for \\\"{}\\\" but the file has {} conflicts\",\n                resolution.hunks.len(),\n                file.path,\n                file.hunks.len()\n            );\n        }\n        if resolution.reasoning.trim().is_empty() {\n            bail!(\"The model returned no reasoning for \\\"{}\\\"\", file.path);\n        }\n        for (hunk_index, hunk) in resolution.hunks.iter().enumerate() {\n            apply::ensure_no_markers(&hunk.resolved_content, &file.path)?;\n            picks[index].insert(\n                hunk_index,\n                apply::HunkPick::Content(hunk.resolved_content.clone()),\n            );\n        }\n        resolved_files[index] = Some(ResolvedFile {\n            path: file.path.clone(),\n            hunks: resolution\n                .hunks\n                .iter()\n                .map(|hunk| hunk.resolved_content.clone())\n                .collect(),\n            reasoning: resolution.reasoning.clone(),\n        });\n    }","sourceCodeStart":622,"sourceCodeEnd":658,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but-api/src/resolve/mod.rs#L622-L658","documentation":"Every file resolution must include a non-empty `reasoning` string explaining the resolution. `validate_ai_response` bails when `resolution.reasoning.trim().is_empty()`, because GitButler surfaces this explanation to the user reviewing AI-resolved conflicts.","triggerScenarios":"The model returns a resolution with `reasoning` missing, empty, or whitespace-only for a file in `resolve_ai_specs` or `resolve_commit_conflicts_with`.","commonSituations":"A smaller/cheaper model omits optional-looking fields; a custom provider strips reasoning to save tokens; JSON post-processing drops empty strings.","solutions":["Retry the request with the prompt explicitly requiring a non-empty reasoning string per file","Patch the response preprocessing to reject/fill empty reasoning before validation (or supply a placeholder only if acceptable)","Switch to a model known to comply with the response schema"],"exampleFix":"// before\n{ path: 'a.txt', hunks: [...], reasoning: '' }\n// after\n{ path: 'a.txt', hunks: [...], reasoning: 'Chose the incoming branch version because ...' }","handlingStrategy":"validation","validationCode":"if (!response.resolutions.every(r => typeof r.reasoning === 'string' && r.reasoning.trim() !== '')) {\n  throw new Error('missing reasoning in AI resolution');\n}","typeGuard":"const hasReasoning = (r: { reasoning?: string }): r is { reasoning: string } =>\n  typeof r.reasoning === 'string' && r.reasoning.trim().length > 0;","tryCatchPattern":"try {\n  await api.resolveCommitConflictsAi(commitId);\n} catch (e) {\n  if (e.message.includes('no reasoning')) await retryRequiringReasoning();\n}","preventionTips":["Mark reasoning as required in the response schema/prompt","Reject or regenerate responses with empty reasoning early","Test with the target model to confirm it always emits reasoning"],"tags":["ai","validation","missing-field"],"backgroundTag":"empty-required-field","analyzedSha":"58e5313667b857ef39a730e380af31816a7b1768","analyzedAt":"2026-09-18T06:50:32.052Z","contentChangedAt":"2026-09-18T06:50:32.052Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}