Preheat the oven to 425°F. Wash and dry the tomatoes. Slice the medium tomatoes in half, leaving the cherry tomatoes whole. Peel the yellow onion and cut it into quarters.
Remove any loose, papery outer layers from the two garlic heads, keeping the bulbs intact. Using a sharp knife, slice approximately ¼–½ inch off the top of each garlic head to expose the individual cloves. Drizzle the exposed cloves with a little olive oil, making sure the oil gets into the garlic. Place both garlic heads cut-side down on the sheet pan so the cloves roast directly against the pan.
Spread the halved tomatoes, cherry tomatoes, and quartered onion across a large rimmed baking sheet. Place the larger tomatoes cut-side up so their juices collect inside as they roast, helping them develop a rich, concentrated flavor without losing too much moisture. Arrange the garlic heads among the vegetables, leaving a little space between everything for even roasting.
Drizzle the vegetables with the remaining olive oil and sprinkle evenly with salt and black pepper. Add the fresh thyme sprigs. Roast on the middle oven rack for 35 minutes, or until the tomatoes are soft and blistered, the onions have golden edges, and the garlic cloves are tender. Some browning around the edges is perfectly normal and adds flavor.
Remove the sheet pan from the oven and allow everything to cool for about 5 minutes. Discard the thyme stems. Carefully squeeze the softened roasted garlic cloves out of their skins, discarding the papery skins.
Transfer the roasted tomatoes, onions, garlic, and all the flavorful juices from the sheet pan into a blender. Add the chicken or vegetable broth, fresh basil, and tomato paste. Blend until smooth and creamy. If using a countertop blender, work in batches and vent the lid carefully to allow steam to escape. Add additional broth if you prefer a thinner consistency.
Pour the blended soup into a large saucepan over medium-low heat. Stir in the heavy cream, freshly grated Parmesan cheese, and butter. Continue stirring gently until the cheese melts and everything is fully incorporated. Avoid bringing the soup to a rapid boil after adding the cream.
Taste the soup and add additional salt or black pepper as needed. For a little extra depth and brightness, stir in 1 teaspoon of balsamic vinegar, if desired. Allow the soup to warm through for another 2–3 minutes.
Ladle the warm soup into bowls and garnish with fresh basil, extra Parmesan cheese, or a small drizzle of heavy cream. Serve with toasted sourdough bread or a homemade grilled cheese sandwich for the ultimate cozy meal.