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

unsupported OpenAI compaction state format: {}

Error message

unsupported OpenAI compaction state format: {}

What it means

Format guard in provider_compaction_items: the stored ProviderCompactionState was written by this backend but carries an unrecognized COMPACTION_STATE_FORMAT version, so its payload cannot be safely interpreted. The canonical replacement window is unavailable to the caller.

Source

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

    Ok(ProviderCompactionState::new(
        owner,
        SharedString::new_static(COMPACTION_STATE_FORMAT),
        serde_json::to_string(&items)?,
    ))
}

/// Recovers the canonical replacement window from `state` if it is owned by
/// `owner`, or `None` when the state belongs to a different backend and the
/// caller should fall back to replaying the full transcript.
pub fn provider_compaction_items(
    state: &ProviderCompactionState,
    owner: &LanguageModelProviderId,
) -> Result<Option<Vec<Value>>> {
    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)

View on GitHub (pinned to 9d272b0363)

Solutions

  1. Fall back to replaying the full transcript (the caller's intended alternative)
  2. Update Zed if the state was written by a newer version
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/open_ai/src/responses.rs:133 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/3ec88d70496238e8. Report an issue: GitHub.