zed-industries/zed · error

unsupported Anthropic compaction state format

Error message

unsupported Anthropic compaction state format: {}

What it means

provider_compaction_encrypted_content validates the compaction state's format tag against the current COMPACTION_STATE_FORMAT; an unknown/older format means the encrypted content cannot be trusted and the state is rejected.

Solutions

  1. Persist compaction state only through the backend that produced it, and route compaction replay to that same backend
  2. Re-compact the thread with the current provider to regenerate state in its expected format
  3. Version the state format string and migrate or discard incompatible stored state instead of erroring mid-request
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/anthropic/src/completion.rs:57 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of zed-industries/zed@916fc2b8cb (2026-08-20). Data as JSON: /api/errors/122ce007afd31c7d. Report an issue: GitHub.

Appendix: source

Thrown at crates/anthropic/src/completion.rs:57

    ProviderCompactionState::new(
        owner,
        SharedString::new_static(COMPACTION_STATE_FORMAT),
        encrypted_content,
    )
}

/// Recovers the `encrypted_content` to round-trip from `state` if it is owned
/// by `owner`, or `None` when the state belongs to a different backend and the
/// summary should be replayed without it.
pub fn provider_compaction_encrypted_content(
    state: &ProviderCompactionState,
    owner: &LanguageModelProviderId,
) -> Result<Option<Arc<str>>> {
    if state.provider_id() != owner {
        return Ok(None);
    }
    if state.format() != COMPACTION_STATE_FORMAT {
        return Err(anyhow!(
            "unsupported Anthropic compaction state format: {}",
            state.format()
        ));
    }
    Ok(Some(state.payload().into()))
}

/// Collects one paused compaction stream into replacement context and usage.
///
/// # Errors
///
/// Returns an error when the stream fails, ends without finalized replacement
/// context, or reports that the provider abandoned compaction.
pub async fn collect_compaction_result(
    mut stream: BoxStream<
        'static,
        Result<LanguageModelCompletionEvent, LanguageModelCompletionError>,
    >,

View on GitHub (pinned to 916fc2b8cb)