Fix flaky test_condenser_metrics_included by creating new action objects (#11555)

Co-authored-by: openhands <openhands@all-hands.dev>
This commit is contained in:
Ray Myers 2025-10-30 09:20:06 -05:00 committed by GitHub
parent 97403dfbdb
commit 58e690ef75
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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