def test_existing_named_conversation_preserves_name_after_agent_interaction(client: R2RClient):
    """Test that an existing conversation with a name preserves that name after agent interaction."""
    # Create a new conversation
    conv_resp = client.conversations.create()
    conversation_id = conv_resp.results.id

    try:
        # Set a specific name for the conversation
        custom_name = f"Custom Conversation Name {uuid.uuid4()}"
        client.conversations.update(
            id=conversation_id,
            name=custom_name
        )

        # Verify the name was set correctly
        conv_overview = client.conversations.list(
            offset=0,
            limit=10,
            # conversation_ids=[conversation_id]
        )
        target_conv = next((c for c in conv_overview.results if str(c.id) == str(conversation_id)), None)
        assert target_conv is not None, "Test conversation not found"
        assert target_conv.name == custom_name, "Custom name not set correctly"

        # Add a message via the agent method
        response = client.retrieval.agent(
            message={"role": "user", "content": "Hello, this is a test message"},
            conversation_id=conversation_id,
        )

        # Verify the conversation still has the same name
        conv_overview = client.conversations.list(
            offset=0,
            limit=100,
            # conversation_ids=[conversation_id]
        )

        target_conv = next((c for c in conv_overview.results if str(c.id) == str(conversation_id)), None)
        assert target_conv is not None, "Test conversation not found"
        assert target_conv.name == custom_name, "Conversation name was changed after agent interaction"

    finally:
        # Cleanup
        client.conversations.delete(id=conversation_id)
Test that an existing conversation with a name preserves that name after agent interaction.
py/tests/integration/test_conversations.py