diff --git a/backend/open_webui/utils/context_compaction.py b/backend/open_webui/utils/context_compaction.py index 1314ef1600..c1a5e07534 100644 --- a/backend/open_webui/utils/context_compaction.py +++ b/backend/open_webui/utils/context_compaction.py @@ -318,6 +318,8 @@ def _apply_latest_summary_checkpoint(messages: list[dict]) -> tuple[list[dict], [{**message, 'contextSummary': None, 'context_summary': None}] ) message = {**message, 'output': trimmed_message['output']} + # A reply compacted on demand still carries the usage of the history its summary replaced. + message = {key: item for key, item in message.items() if key != 'usage'} return [message, *messages[idx + 1 :]], value marker = next(