Heat a large Dutch oven or large pot over medium heat, add the olive oil and heat through. Add the butter and allow to melt. Add the onions and toss quickly to remove the moisture from the onions.
Sauté until the onions are soft and tender, about 10 minutes, then sprinkle the sugar and salt over the onions (to help them caramelize) and reduce the heat to medium-low and cook, stirring occasionally, until the onions are uniformly brown and caramelized, about 30 to 45 minutes.
Add the garlic, bay leaves and thyme, stirring to combine. Pour in the wine to deglaze the pot, and bring to a boil, reduce the heat, and simmer until the wine has almost evaporated, about 5 minutes. Add the beef broth, bring the soup back to a simmer and cook for 20 minutes. Discard the bay leaves and thyme sprigs.
Heat the broiler to high. Ladle the soup into ceramic dishes. Add a finishing splash of brandy, if desired.
Arrange the toasted baguette slices on top of each bowl of soup in single layer so that the surface of the soup of each is covered. Generously top with Gruyere cheese, and broil until bubbly and golden brown, about 3 minutes. Serve immediately.