{"record":{"id":"54d79b1236b231f7","repo":"Hmbown/CodeWhale","slug":"compaction-summary-response-incomplete-provider-s","errorCode":null,"errorMessage":"Compaction summary response incomplete: provider stop reason `{}`; the partial summary was not accepted.","messagePattern":"Compaction summary response incomplete: provider stop reason `(.+?)`; the partial summary was not accepted\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/compaction.rs","lineNumber":1273,"sourceCode":"            cost_scope,\n            config.runtime_cost_owner.as_deref(),\n            &format!(\n                \"compaction:dispatch:{}:response:{}\",\n                cost_route\n                    .dispatched_at\n                    .timestamp_nanos_opt()\n                    .unwrap_or_default(),\n                response.id\n            ),\n            &cost_route,\n            &response.usage,\n        );\n\n        // Usage above is already billed; a provider-declared incomplete\n        // summary must still fail rather than replace the session history\n        // with a fragment.\n        if crate::models::is_incomplete_stop_reason(response.stop_reason.as_deref()) {\n            anyhow::bail!(\n                \"Compaction summary response incomplete: provider stop reason `{}`; the partial summary was not accepted.\",\n                crate::models::stop_reason_detail(response.stop_reason.as_deref())\n            );\n        }\n\n        let summary = response\n            .content\n            .iter()\n            .filter_map(|block| match block {\n                ContentBlock::Text { text, .. } => Some(text.clone()),\n                _ => None,\n            })\n            .collect::<Vec<_>>()\n            .join(\"\\n\");\n\n        if let Err(error) = validate_compaction_summary(&summary) {\n            if quality_retry_used {\n                return Err(error.context(","sourceCodeStart":1255,"sourceCodeEnd":1291,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/8880682c63083a91624de936797efa3ce9e498fd/crates/tui/src/compaction.rs#L1255-L1291","documentation":"The summary request finished with a provider stop reason classified as incomplete (e.g. length/max_tokens or content filter). Usage was already billed and recorded, but the fragment is not accepted as the session checkpoint (crates/tui/src/compaction.rs:1273); the message includes stop_reason_detail to distinguish causes.","triggerScenarios":"Compaction output-token budget smaller than the summary a long session needs; provider-side length caps; content-filter truncation of the summary itself.","commonSituations":"Very long sessions compacted in one shot; default max output tokens too low for the summary model; strict providers that truncate aggressively.","solutions":["Raise the compaction output-token budget in config","If the stop reason is content_filter, compact earlier so less sensitive material accumulates, or change models","Retry once - truncation can be borderline and stochastic on similar lengths","Compact more frequently so each individual summary is smaller"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Before compacting, budget output tokens against session size\nlet out_tokens = cfg.compaction_max_output_tokens();\nensure!(out_tokens as u64 >= estimated_summary_tokens(&messages), \"output budget too small; will truncate\");","typeGuard":"fn is_incomplete_summary(msg: &str) -> bool {\n    msg.contains(\"Compaction summary response incomplete\")\n}","tryCatchPattern":"// Read stop_reason_detail from the message: raise budget for `length`, change model for `content_filter`\nif is_incomplete_summary(&e.to_string()) {\n    if e.to_string().contains(\"length\") || e.to_string().contains(\"max\") {\n        raise_output_budget_and_retry();\n    } else {\n        switch_compaction_model();\n    }\n}","preventionTips":["Set compaction output tokens generously - longer than any expected summary","Compact more often so individual summaries stay short","Remember the partial is billed but never applied"],"tags":["compaction","stop-reason","max-tokens","provider"],"backgroundTag":null,"analyzedSha":"8880682c63083a91624de936797efa3ce9e498fd","analyzedAt":"2026-08-16T11:31:27.956Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}