zed-industries/zed · error

No edit history hunks found in response

Error message

No edit history hunks found in response

What it means

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.

Source

Thrown at crates/edit_prediction_cli/src/synthesize.rs:588

        .map(|l| l.strip_prefix("NAME:").unwrap_or("").trim().to_string())
        .unwrap_or_else(|| "unnamed example".to_string());

    // Parse ANALYSIS section (Claude's planning) - this is the primary reasoning
    let reasoning = extract_section(
        response,
        "ANALYSIS:",
        &["NAME:", "REASONING:", "EDIT_HISTORY:", "EXPECTED_PATCH:"],
    )
    .unwrap_or_default();

    // Parse EDIT_HISTORY diff block
    let edit_history_hunks = extract_diff_block(response, "EDIT_HISTORY:")?;

    // Parse EXPECTED_PATCH diff block
    let expected_patch_hunks = extract_diff_block(response, "EXPECTED_PATCH:")?;

    if edit_history_hunks.is_empty() {
        anyhow::bail!("No edit history hunks found in response");
    }
    if expected_patch_hunks.is_empty() {
        anyhow::bail!("No expected patch hunks found in response");
    }

    Ok(Some(ClaudeResponse {
        name,
        reasoning,
        edit_history_hunks,
        expected_patch_hunks,
    }))
}

fn extract_section(text: &str, start_marker: &str, end_markers: &[&str]) -> Option<String> {
    let start_idx = text.find(start_marker)?;
    let content_start = start_idx + start_marker.len();

    let end_idx = end_markers

View on GitHub (pinned to f4178619ac)

Solutions

  1. Inspect the raw model response to see what was actually produced under EDIT_HISTORY:
  2. Retry generation — single-shot format misses are often stochastic
  3. Tighten the prompt's output-format instructions with a concrete filled-in example
  4. If responses are truncated, raise the max output tokens for the generation call
Defensive patterns

Strategy: retry

Validate before calling

if !response.contains("EDIT_HISTORY:") || !has_fenced_block_after(response, "EDIT_HISTORY:") {
    // regenerate before attempting to parse
}

Try / catch

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.

Prevention

When it happens

Trigger: 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.

Common situations: Model not following the output template; response cut off by a token limit; prompt format drift after switching models; heading renamed by the model.

Related errors


AI-assisted analysis of zed-industries/zed@f4178619ac (2026-08-20). Data as JSON: /api/errors/037dd2777fde3d16. Report an issue: GitHub.