From 2616b57d37de735ac7c21a63151534c4a2f7d11b Mon Sep 17 00:00:00 2001 From: CLFutureX Date: Wed, 5 Nov 2025 16:55:57 +0800 Subject: [PATCH 1/2] Condensation triggered by a condensation request should be calculated based on the view size Signed-off-by: CLFutureX --- .../sdk/context/condenser/llm_summarizing_condenser.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/openhands-sdk/openhands/sdk/context/condenser/llm_summarizing_condenser.py b/openhands-sdk/openhands/sdk/context/condenser/llm_summarizing_condenser.py index 2ba289aad4..408c0be821 100644 --- a/openhands-sdk/openhands/sdk/context/condenser/llm_summarizing_condenser.py +++ b/openhands-sdk/openhands/sdk/context/condenser/llm_summarizing_condenser.py @@ -38,6 +38,10 @@ def should_condense(self, view: View) -> bool: def get_condensation(self, view: View) -> Condensation: head = view[: self.keep_first] target_size = self.max_size // 2 + if view.unhandled_condensation_request: + # Condensation triggered by a condensation request + # should be calculated based on the view size. + target_size = len(view) // 2 # Number of events to keep from the tail -- target size, minus however many # prefix events from the head, minus one for the summarization event events_from_tail = target_size - len(head) - 1 From 2c81419bc4eb1ad7d26692c57d6e31199e91b03f Mon Sep 17 00:00:00 2001 From: enyst Date: Mon, 10 Nov 2025 03:57:58 +0000 Subject: [PATCH 2/2] style(condenser): apply pre-commit formatting to llm_summarizing_condenser.py to satisfy CI Co-authored-by: openhands --- .../sdk/context/condenser/llm_summarizing_condenser.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openhands-sdk/openhands/sdk/context/condenser/llm_summarizing_condenser.py b/openhands-sdk/openhands/sdk/context/condenser/llm_summarizing_condenser.py index 408c0be821..3500da92cf 100644 --- a/openhands-sdk/openhands/sdk/context/condenser/llm_summarizing_condenser.py +++ b/openhands-sdk/openhands/sdk/context/condenser/llm_summarizing_condenser.py @@ -39,7 +39,7 @@ def get_condensation(self, view: View) -> Condensation: head = view[: self.keep_first] target_size = self.max_size // 2 if view.unhandled_condensation_request: - # Condensation triggered by a condensation request + # Condensation triggered by a condensation request # should be calculated based on the view size. target_size = len(view) // 2 # Number of events to keep from the tail -- target size, minus however many