{"record":{"id":"122ce007afd31c7d","repo":"zed-industries/zed","slug":"unsupported-anthropic-compaction-state-format","errorCode":null,"errorMessage":"unsupported Anthropic compaction state format: {}","messagePattern":"unsupported Anthropic compaction state format: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/anthropic/src/completion.rs","lineNumber":56,"sourceCode":"    ProviderCompactionState::new(\n        owner,\n        SharedString::new_static(COMPACTION_STATE_FORMAT),\n        encrypted_content,\n    )\n}\n\n/// Recovers the `encrypted_content` to round-trip from `state` if it is owned\n/// by `owner`, or `None` when the state belongs to a different backend and the\n/// summary should be replayed without it.\npub fn provider_compaction_encrypted_content(\n    state: &ProviderCompactionState,\n    owner: &LanguageModelProviderId,\n) -> Result<Option<Arc<str>>> {\n    if state.provider_id() != owner {\n        return Ok(None);\n    }\n    if state.format() != COMPACTION_STATE_FORMAT {\n        return Err(anyhow!(\n            \"unsupported Anthropic compaction state format: {}\",\n            state.format()\n        ));\n    }\n    Ok(Some(state.payload().into()))\n}\n\n#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]\npub enum AnthropicPromptCacheMode {\n    Disabled,\n    Legacy,\n    #[default]\n    Automatic,\n}\n\nfn set_cache_control(content: &mut RequestContent, cache_control: Option<CacheControl>) -> bool {\n    match content {\n        RequestContent::RedactedThinking { .. } => false,","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/zed-industries/zed/blob/bc538def4545534201bbfcac4e95ac34ea6501b6/crates/anthropic/src/completion.rs#L38-L74","documentation":"Anthropic thread compaction can be resumed using provider-encrypted state (encrypted_content). provider_compaction_encrypted_content checks that the stored state belongs to Anthropic (provider_id matches) and that its format tag equals COMPACTION_STATE_FORMAT. A mismatch means the state was written by code using a different format version, so it cannot be safely decoded and the request cannot be built.","triggerScenarios":"Loading a persisted conversation whose compaction state was serialized by a different Zed version (after upgrade or downgrade); a state row whose format tag changed or was corrupted; format evolution without a migration path.","commonSituations":"Rolling Zed back after an upgrade; opening old local thread databases; forward/backward migrations that changed the compaction-state format string.","solutions":["Upgrade Zed to the version that wrote the state (or the latest release) and reopen the thread.","Start a new conversation or trigger a fresh compaction so the state is rewritten in the current format.","As a developer: when changing COMPACTION_STATE_FORMAT, write a migration for old payloads instead of erroring on read."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if state.provider_id() == owner && state.format() != COMPACTION_STATE_FORMAT {\n    // do not call provider_compaction_encrypted_content;\n    // prompt for a new conversation or a fresh compaction instead\n}","typeGuard":"fn is_decodable_compaction_state(\n    state: &ProviderCompactionState,\n    owner: &LanguageModelProviderId,\n) -> bool {\n    state.provider_id() == owner && state.format() == COMPACTION_STATE_FORMAT\n}","tryCatchPattern":null,"preventionTips":["Version compaction state and write migrations whenever COMPACTION_STATE_FORMAT changes.","Include the writer version in the payload for diagnostics.","On load failure, guide the user to start a new thread instead of retrying the same state."],"tags":["anthropic","zed","compaction","version-mismatch","state-serialization"],"backgroundTag":null,"analyzedSha":"bc538def4545534201bbfcac4e95ac34ea6501b6","analyzedAt":"2026-08-16T07:30:46.435Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}