{"record":{"id":"037dd2777fde3d16","repo":"zed-industries/zed","slug":"no-edit-history-hunks-found-in-response","errorCode":null,"errorMessage":"No edit history hunks found in response","messagePattern":"No edit history hunks found in response","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/edit_prediction_cli/src/synthesize.rs","lineNumber":588,"sourceCode":"        .map(|l| l.strip_prefix(\"NAME:\").unwrap_or(\"\").trim().to_string())\n        .unwrap_or_else(|| \"unnamed example\".to_string());\n\n    // Parse ANALYSIS section (Claude's planning) - this is the primary reasoning\n    let reasoning = extract_section(\n        response,\n        \"ANALYSIS:\",\n        &[\"NAME:\", \"REASONING:\", \"EDIT_HISTORY:\", \"EXPECTED_PATCH:\"],\n    )\n    .unwrap_or_default();\n\n    // Parse EDIT_HISTORY diff block\n    let edit_history_hunks = extract_diff_block(response, \"EDIT_HISTORY:\")?;\n\n    // Parse EXPECTED_PATCH diff block\n    let expected_patch_hunks = extract_diff_block(response, \"EXPECTED_PATCH:\")?;\n\n    if edit_history_hunks.is_empty() {\n        anyhow::bail!(\"No edit history hunks found in response\");\n    }\n    if expected_patch_hunks.is_empty() {\n        anyhow::bail!(\"No expected patch hunks found in response\");\n    }\n\n    Ok(Some(ClaudeResponse {\n        name,\n        reasoning,\n        edit_history_hunks,\n        expected_patch_hunks,\n    }))\n}\n\nfn extract_section(text: &str, start_marker: &str, end_markers: &[&str]) -> Option<String> {\n    let start_idx = text.find(start_marker)?;\n    let content_start = start_idx + start_marker.len();\n\n    let end_idx = end_markers","sourceCodeStart":570,"sourceCodeEnd":606,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/edit_prediction_cli/src/synthesize.rs#L570-L606","documentation":"Bailed while parsing the Claude-style generation response in synthesize: the `EDIT_HISTORY:` section was missing from the response or contained no parseable fenced diff block. The response template requires fenced diff blocks under both `EDIT_HISTORY:` and `EXPECTED_PATCH:`; an example is only usable when both parse.","triggerScenarios":"The generation model omits the EDIT_HISTORY section, writes it without a fenced code block, or truncates the response (max output tokens) before reaching it — extract_diff_block then returns no hunks.","commonSituations":"Model not following the output template; response cut off by a token limit; prompt format drift after switching models; heading renamed by the model.","solutions":["Inspect the raw model response to see what was actually produced under EDIT_HISTORY:","Retry generation — single-shot format misses are often stochastic","Tighten the prompt's output-format instructions with a concrete filled-in example","If responses are truncated, raise the max output tokens for the generation call"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"if !response.contains(\"EDIT_HISTORY:\") || !has_fenced_block_after(response, \"EDIT_HISTORY:\") {\n    // regenerate before attempting to parse\n}","typeGuard":null,"tryCatchPattern":"On this parse bail, log the raw response, retry generation (optionally feeding the parse failure back as a corrective message), and only drop the sample after a bounded number of retries.","preventionTips":["Pre-check responses for the required section markers before parsing","Include a complete filled-in example in the generation prompt","Set max output tokens high enough that EDIT_HISTORY is never truncated away"],"tags":["llm-parsing","synthesize","edit-prediction","rust"],"backgroundTag":"llm-response-parse-failed","analyzedSha":"f4178619acd0d47ea1f76a2025c42962c6d6638c","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}