File tree Expand file tree Collapse file tree 3 files changed +44
-1
lines changed
openhands-sdk/openhands/sdk Expand file tree Collapse file tree 3 files changed +44
-1
lines changed Original file line number Diff line number Diff line change 1717 UserRejectObservation ,
1818)
1919from openhands .sdk .event .base import Event
20- from openhands .sdk .event .condenser import Condensation
20+ from openhands .sdk .event .condenser import Condensation , CondensationRequest
2121
2222
2323# These are external inputs
@@ -252,6 +252,19 @@ def _create_event_panel(self, event: Event) -> Panel | None:
252252 border_style = _SYSTEM_COLOR ,
253253 expand = True ,
254254 )
255+
256+ elif isinstance (event , CondensationRequest ):
257+ title = f"[bold { _SYSTEM_COLOR } ]"
258+ if self ._name :
259+ title += f"{ self ._name } "
260+ title += f"Condensation Request[/bold { _SYSTEM_COLOR } ]"
261+ return Panel (
262+ content ,
263+ title = title ,
264+ border_style = _SYSTEM_COLOR ,
265+ padding = _PANEL_PADDING ,
266+ expand = True ,
267+ )
255268 else :
256269 # Fallback panel for unknown event types
257270 title = f"[bold { _ERROR_COLOR } ]"
Original file line number Diff line number Diff line change @@ -55,6 +55,17 @@ class CondensationRequest(Event):
5555
5656 source : SourceType = "environment"
5757
58+ @property
59+ def visualize (self ) -> Text :
60+ text = Text ()
61+ text .append ("Conversation Condensation Requested\n " , style = "bold" )
62+ message = (
63+ "A condensation of the conversation history has been requested to "
64+ "manage context window usage.\n "
65+ )
66+ text .append (message )
67+ return text
68+
5869
5970class CondensationSummaryEvent (LLMConvertibleEvent ):
6071 """This event represents a summary generated by a condenser."""
Original file line number Diff line number Diff line change 1111from openhands .sdk .event import (
1212 ActionEvent ,
1313 AgentErrorEvent ,
14+ CondensationRequest ,
1415 MessageEvent ,
1516 ObservationEvent ,
1617 PauseEvent ,
@@ -291,6 +292,24 @@ def test_visualizer_user_reject_observation_panel():
291292 assert "User rejected the proposed action." in renderable .plain
292293
293294
295+ def test_visualizer_condensation_request_panel ():
296+ """CondensationRequest should render a system-styled panel with friendly text."""
297+ visualizer = DefaultConversationVisualizer ()
298+ event = CondensationRequest ()
299+ panel = visualizer ._create_event_panel (event )
300+ assert panel is not None
301+ # Should not fall back to UNKNOWN
302+ assert "UNKNOWN Event" not in str (panel .title )
303+ # Title should indicate condensation request (case-insensitive check on substring)
304+ assert "Condensation Request" in str (panel .title )
305+ # Body should be the friendly visualize text
306+ renderable = panel .renderable
307+ assert isinstance (renderable , Text )
308+ body = renderable .plain
309+ assert "Conversation Condensation Requested" in body
310+ assert "condensation of the conversation history" in body
311+
312+
294313def test_metrics_formatting ():
295314 """Test metrics subtitle formatting."""
296315 from unittest .mock import MagicMock
You can’t perform that action at this time.
0 commit comments