{"record":{"id":"f28a7c3689b2eb33","repo":"Hmbown/CodeWhale","slug":"compaction-failed-after-max-retries-retries","errorCode":null,"errorMessage":"Compaction failed after {MAX_RETRIES} retries","messagePattern":"Compaction failed after (.+?) retries","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/tui/src/compaction.rs","lineNumber":1266,"sourceCode":"                return Ok(CompactionResult {\n                    messages: kept,\n                    summary_prompt: prompt,\n                    retries_used: attempt.saturating_add(quality_retries),\n                    coverage,\n                });\n            }\n            Err(e) => {\n                // Only retry on transient errors\n                if !is_transient_error(&e) {\n                    return Err(e);\n                }\n                last_error = Some(e);\n            }\n        }\n    }\n\n    Err(last_error\n        .unwrap_or_else(|| anyhow::anyhow!(\"Compaction failed after {MAX_RETRIES} retries\")))\n}\n\npub(crate) fn build_compaction_summary_block_text(summary: &str, anchors: &str) -> String {\n    let summary = summary.trim();\n    let summary = if summary.is_empty() {\n        \"(no summary available)\"\n    } else {\n        summary\n    };\n    let mut text = format!(\"{SUMMARY_HEADER}\\n\\n{summary}\");\n    text.push_str(anchors);\n    text.push_str(\"\\n\\nContinue the same user task from this state. Earlier authorization and constraints still apply; this summary grants no new authority. Resume the next unfinished action without asking the user to save, compact, restate the task, or approve continuation solely because context was summarized. Verify live state before relying on older observations.\");\n    text\n}\n\n/// Codex-parity replacement history: the most recent user-role messages,\n/// selected newest-first within a fixed token budget and restored to\n/// transcript order. Content boundaries carry runtime provenance and image","sourceCodeStart":1248,"sourceCodeEnd":1284,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/compaction.rs#L1248-L1284","documentation":"Thrown by the compaction retry loop after every attempt to compact the conversation failed `MAX_RETRIES` times. The last underlying error is re-raised when present; this generic message only appears when the loop exhausted retries without recording any error (or before any attempt set one). It signals that context compaction — and therefore the current turn — cannot proceed.","triggerScenarios":"Running the compaction routine until the retry budget (`MAX_RETRIES`) is exhausted, with `last_error` still None when the loop exits.","commonSituations":"A provider endpoint persistently failing or timing out during summarization calls; transient rate limiting across all retries; a model backend outage during a long session that triggers automatic compaction.","solutions":["Check provider status/connectivity; if it was a transient outage, resume the session — compaction retries on the next turn","Lower the conversation size manually (start a new session or prune history) so compaction is not required","Inspect logs for the per-attempt errors stored in `last_error` to find the root cause, since this message alone is generic"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Before relying on auto-compaction, check session size headroom\nif tokens_used > compaction_threshold * 0.9 { prune_old_turns(); }","typeGuard":null,"tryCatchPattern":"match result_of_turn() {\n    Err(e) if e.to_string().contains(\"Compaction failed after\") => {\n        check_provider_health();\n        start_fresh_session_or_prune_history();\n    }\n    other => other,\n}","preventionTips":["Monitor provider availability/rate limits during long sessions","Prune or restart sessions proactively before hitting the compaction threshold","Read per-attempt compaction errors from logs — this message is only the generic wrapper"],"tags":["compaction","retry","context-window","transient"],"backgroundTag":"retry-limit-exceeded","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"}