def test_get_contextual_events_all_events_filtered():
    """
    Tests behavior when all events in the context window are of types
    that should be filtered out.
    """
    mock_event_stream = MagicMock(spec=EventStream)
    target_event_id = (
        2  # Target event itself might be filtered or not, doesn't matter for this test
    )

    # All events are of types that should be filtered by the default filter in _get_contextual_events
    # create_test_events(all_event_specs) # Not strictly needed as search_events will return []

    # search_events, after applying the internal EventFilter, will return empty lists
    simulated_search_before = []
    simulated_search_after = []

    mock_event_stream.search_events.side_effect = [
        simulated_search_before,
        simulated_search_after,
    ]

    result_str = _get_contextual_events(mock_event_stream, target_event_id)

    expected_output_str = ''  # Empty string as all events are filtered

    assert result_str == expected_output_str

    calls = mock_event_stream.search_events.call_args_list
    assert len(calls) == 2  # Still called twice

    # Check the filter properties on one of the calls (they should be identical)
    filter_used = calls[0][1]['filter']
    expected_filtered_types = (
        NullAction,
        NullObservation,
        ChangeAgentStateAction,
        AgentStateChangedObservation,
    )
    assert isinstance(filter_used, EventFilter)
    assert filter_used.exclude_hidden is True
    assert set(filter_used.exclude_types) == set(expected_filtered_types)

    Tests behavior when all events in the context window are of types
    that should be filtered out.
    
tests/unit/test_contextual_events.py