zed-industries/zed · error · anyhow::Error

OpenAI returned an empty compaction output

Error message

OpenAI returned an empty compaction output

What it means

Validation in validate_compaction_items: the compaction output from OpenAI deserialized to an empty item list, so there is no replacement window to store; accepting it would silently lose the compacted context.

Source

Thrown at crates/open_ai/src/responses.rs:147

    if state.provider_id() != owner {
        return Ok(None);
    }
    if state.format() != COMPACTION_STATE_FORMAT {
        return Err(anyhow!(
            "unsupported OpenAI compaction state format: {}",
            state.format()
        ));
    }

    let items = serde_json::from_str::<Vec<Value>>(state.payload())
        .context("malformed OpenAI compaction state payload")?;
    validate_compaction_items(&items)?;
    Ok(Some(items))
}

fn validate_compaction_items(items: &[Value]) -> Result<()> {
    if items.is_empty() {
        return Err(anyhow!("OpenAI returned an empty compaction output"));
    }
    if !items.iter().any(|item| {
        item.get("type")
            .and_then(Value::as_str)
            .is_some_and(|item_type| {
                matches!(
                    item_type,
                    "compaction" | "compaction_summary" | "context_compaction"
                )
            })
    }) {
        let item_types = items
            .iter()
            .filter_map(|item| item.get("type").and_then(Value::as_str))
            .collect::<Vec<_>>()
            .join(", ");
        return Err(anyhow!(
            "OpenAI compaction output did not contain a recognized compaction item \

View on GitHub (pinned to 9d272b0363)

Solutions

  1. Retry the compaction/completion request
  2. Fall back to replaying the full transcript for this turn
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/open_ai/src/responses.rs:147 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of zed-industries/zed@9d272b0363 (2026-08-20). Data as JSON: /api/errors/5bed0c6e2a8ba375. Report an issue: GitHub.