From 58e690ef753132fa688045430c670d37a04fe920 Mon Sep 17 00:00:00 2001 From: Ray Myers Date: Thu, 30 Oct 2025 09:20:06 -0500 Subject: [PATCH] Fix flaky test_condenser_metrics_included by creating new action objects (#11555) Co-authored-by: openhands --- tests/unit/controller/test_agent_controller.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/tests/unit/controller/test_agent_controller.py b/tests/unit/controller/test_agent_controller.py index 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_agent mock_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_event return action mock_agent.step = agent_step_fn