From 78fa1fb1e1497c7d59e7b75db60a5b7517a5f6d1 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Thu, 28 May 2026 04:19:18 +0000 Subject: [PATCH] fix(compact_20260112): surface warning-only applied edits in response `applied_edits_for_response()` previously hid `compact_20260112` edits when they had only warnings (no compaction block, no error). This dropped diagnostically important warnings such as `unsupported_trigger_type_X_using_input_tokens` and `pause_after_compaction_ignored` whenever the conversation was under the trigger threshold. Operators now see these warnings in the response. Co-authored-by: Yassin Kortam --- .../context_management/result.py | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/litellm/llms/anthropic/experimental_pass_through/context_management/result.py b/litellm/llms/anthropic/experimental_pass_through/context_management/result.py index 2763f272868..36bcde98d0c 100644 --- a/litellm/llms/anthropic/experimental_pass_through/context_management/result.py +++ b/litellm/llms/anthropic/experimental_pass_through/context_management/result.py @@ -29,18 +29,24 @@ class PolyfillResult: """``applied_edits`` to attach on the client-visible response. ``compact_20260112`` is included when a new compaction block was - synthesized (success) OR when the edit carries an ``error`` field + synthesized (success), when the edit carries an ``error`` field (``summary_model_not_configured``, ``summary_call_failed``, - ``summary_extraction_failed``) — operators and clients need to see - why compaction was requested but not applied. Slice-only / - under-threshold paths that produced no edit at all are omitted. - Other edit types are included when the editor returned an - ``AppliedEdit``. + ``summary_extraction_failed``), or when the edit carries + ``warnings`` (e.g. ``unsupported_trigger_type_X_using_input_tokens``, + ``pause_after_compaction_ignored``) — operators and clients need to + see why compaction was requested but not applied as expected. + Slice-only / under-threshold paths that produced no edit at all + (no block, no error, no warnings) are omitted. Other edit types are + included when the editor returned an ``AppliedEdit``. """ visible: List[AppliedEdit] = [] for edit in self.applied_edits: if edit.get("type") == COMPACT_EDIT_TYPE: - if self.compaction_block is not None or edit.get("error"): + if ( + self.compaction_block is not None + or edit.get("error") + or edit.get("warnings") + ): visible.append(edit) else: visible.append(edit)