π OpenHands: AI-Driven Development
Fix flaky test_condenser_metrics_included by creating new action objects (#11555)
Ray Myers58e690ef7531
diff --git a/tests/unit/controller/test_agent_controller.py b/tests/unit/controller/test_agent_controller.pyindex 0158e7e5e4..2aa5192c7c 100644--- a/tests/unit/controller/test_agent_controller.py+++ b/tests/unit/controller/test_agent_controller.py@@ -1582,16 +1582,15 @@ async def test_condenser_metrics_included(mock_agent_with_stats, test_event_stre# Attach the condenser to the mock_agentmock_agent.condenser = condenser- # Create a real CondensationAction- action = CondensationAction(- forgotten_events_start_id=1,- forgotten_events_end_id=5,- summary='Test summary',- summary_offset=1,- )- action._source = EventSource.AGENT # Required for event_stream.add_event-def agent_step_fn(state):+ # Create a new CondensationAction each time to avoid ID reuse+ action = CondensationAction(+ forgotten_events_start_id=1,+ forgotten_events_end_id=5,+ summary='Test summary',+ summary_offset=1,+ )+ action._source = EventSource.AGENT # Required for event_stream.add_eventreturn actionmock_agent.step = agent_step_fn