async def test_generate_conversation_title_long_title():
    """Test that long titles are truncated."""
    # Create a proper mock response with a long title
    mock_response = MagicMock()
    mock_response.choices = [MagicMock()]
    mock_response.choices[
        0
    ].message.content = 'This is a very long title that should be truncated because it exceeds the maximum length'

    # Create a mock LLM instance with a synchronous completion method
    mock_llm = MagicMock()
    mock_llm.completion = MagicMock(return_value=mock_response)

    # Patch the LLM class to return our mock
    with patch('openhands.utils.conversation_summary.LLM', return_value=mock_llm):
        result = await generate_conversation_title(
            'Can you help me with Python?', LLMConfig(model='test-model'), max_length=30
        )

    # Verify the title is truncated correctly
    assert len(result) <= 30
    assert result.endswith('...')
Test that long titles are truncated.
tests/unit/test_conversation_summary.py