diff --git a/plugins/platforms/matrix/adapter.py b/plugins/platforms/matrix/adapter.py index f86a45366f7..a49a99bdd0e 100644 --- a/plugins/platforms/matrix/adapter.py +++ b/plugins/platforms/matrix/adapter.py @@ -837,6 +837,12 @@ class MatrixAdapter(BasePlatformAdapter): # (see _normalize_matrix_bang_command), so instruction text shows "!". typed_command_prefix = "!" + # Class-level defaults so partially-constructed instances (tests build + # adapters via object.__new__ without __init__) keep working; __init__ + # overrides both from _resolve_max_message_length(). + max_message_length = DEFAULT_MAX_MESSAGE_LENGTH + _split_threshold = DEFAULT_MAX_MESSAGE_LENGTH - 100 + def __init__(self, config: PlatformConfig): super().__init__(config, Platform.MATRIX) diff --git a/tests/gateway/test_text_batching.py b/tests/gateway/test_text_batching.py index d72cb439d47..6c0cdaa6d9f 100644 --- a/tests/gateway/test_text_batching.py +++ b/tests/gateway/test_text_batching.py @@ -278,9 +278,9 @@ class TestMatrixTextBatching: @pytest.mark.asyncio async def test_adaptive_delay_for_near_limit_chunk(self): - """Chunks near the 4000-char limit should trigger longer delay.""" + """Chunks near the outbound limit should trigger longer delay.""" adapter = _make_matrix_adapter() - long_text = "x" * 3950 + long_text = "x" * (adapter._split_threshold + 50) adapter._enqueue_text_event(_make_event(long_text, Platform.MATRIX)) await asyncio.sleep(0.15)