{"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":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/compaction.rs","lineNumber":1664,"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 codewhale_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                codewhale_models::stop_reason_detail(response.stop_reason.as_deref())\n            );\n        }\n        if response\n            .content\n            .iter()\n            .any(|block| matches!(block, ContentBlock::ToolUse { .. }))\n        {\n            anyhow::bail!(\n                \"Compaction returned a tool call instead of a completed handoff; original conversation was preserved.\"\n            );\n        }\n\n        let summary = response\n            .content\n            .iter()\n            .filter_map(|block| match block {","sourceCodeStart":1646,"sourceCodeEnd":1682,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/compaction.rs#L1646-L1682","documentation":"After a summary request, the library checks the provider-declared stop reason; a stop reason classified as incomplete (e.g. max tokens, length cutoff) means the summary is a fragment. Since usage is already billed but the summary is truncated, the library fails rather than replace session history with an incomplete summary.","triggerScenarios":"A compaction summary request returns with `response.stop_reason` that `codewhale_models::is_incomplete_stop_reason` classifies as incomplete (e.g. length/max-token truncation).","commonSituations":"Summary output budget (max_tokens) too small for a long conversation; a provider change in stop-reason strings; a slow/local model hitting a token ceiling mid-summary.","solutions":["Increase max output tokens on the compaction/summary request so the summary fits.","Reduce input scope (compact earlier, or summarize in chunks) so the summary needs fewer tokens.","Check the provider's stop-reason value against `is_incomplete_stop_reason` to confirm what triggered the cutoff.","Retry with a model/context window that can emit a complete summary.","The original history is preserved — no data is lost; re-run compaction after fixing the limit."],"exampleFix":"// before: summary truncated at default token cap\nlet resp = model.request(req, /* max_tokens */ 512);\n// after\nlet resp = model.request(req, /* max_tokens */ 4096);","handlingStrategy":"validation","validationCode":"fn incomplete(resp: &Response) -> bool {\n    codewhale_models::is_incomplete_stop_reason(resp.stop_reason.as_deref())\n}","typeGuard":"if incomplete(&response) { /* reject before applying */ }","tryCatchPattern":"match compaction::summarize(&history) {\n    Err(e) if e.to_string().contains(\"incomplete\") => {\n        // raise token budget and retry once\n        retry_with_larger_max_tokens()\n    }\n    other => other,\n}","preventionTips":["Set max_tokens high enough for the worst-case summary size","Compact before the history grows too large","Monitor provider stop reasons in logs","Prefer models with adequate output limits"],"tags":["compaction","truncated-response","stop-reason"],"backgroundTag":"unexpected-response-shape","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}