From b17a8c2acf9afdd80f1e3745c46acd0b2e54eae2 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Wed, 27 May 2026 17:19:18 +0000 Subject: [PATCH] fix(compact): reduce to last user question when summary_model not configured but prior compaction block exists Aligns the summary_model_not_configured path with the under-threshold and client-compaction-block paths, which both reduce post-compaction messages to just the latest user question so the downstream provider doesn't get the summary on system prefix AND the full post-compaction history. Co-authored-by: Yassin Kortam --- .../context_management/editors/compact.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/litellm/llms/anthropic/experimental_pass_through/context_management/editors/compact.py b/litellm/llms/anthropic/experimental_pass_through/context_management/editors/compact.py index c23461bcd9b..14412403281 100644 --- a/litellm/llms/anthropic/experimental_pass_through/context_management/editors/compact.py +++ b/litellm/llms/anthropic/experimental_pass_through/context_management/editors/compact.py @@ -511,6 +511,11 @@ async def apply_compact_20260112( summary_model = _read_summary_model_setting() if summary_model is None: applied["error"] = "summary_model_not_configured" + if prior_compaction_block is not None: + # Prior context lives in ``augmented_system`` (compaction summary + # prefix); reduce to the latest user question to avoid re-sending + # stale post-compaction turns the summary already covers. + downstream_messages = _select_last_user_question(effective_messages) return PolyfillResult( messages=downstream_messages, system=augmented_system,