This is what I and another person who's a native speaker think:
The former is the correct alternative. If it was a longer sentence, you'd probably have to add a comma after prevent, but in this case and as the sentence is, you only need one comma after but.
As a very detail-oriented person who has spent years on learning and teaching English, I cannot remember a single example of a use of but without a comma beforehand in any well-written books so far for similar sentences (not shorter/different ones), but as I'm googling now, I find out another question on ELU talking about this: Using a comma before "but", but that slightly contradicts what I've thought so far.
There are also punctuation rules on the website of University of Sussex
A joining comma must be followed by one of the connecting words and,
or, but, yet or while: The report was due last week, but it hasn't
appeared yet. The motorways in France and Spain are toll roads, while
those in Britain are free.
A gapping comma indicates that you have
decided not to repeat some words which have already occurred in the
Jupiter is the largest planet and Pluto, the smallest.
It also continues to say:
If you're not sure about your commas, you can check them by using
these rules. Ask yourself these questions:
- Can the comma be replaced by and or or?
- Is it followed by one of the connecting words and, or, but, yet or while?
- Does it represent the absence of repetition?
- Does it form one of a pair of commas setting off an interruption which could be removed from the sentence?
It also sums it up this way:
- Use a listing comma in a list where and or or would be possible
- Use a joining comma before and, or, but, yet or while
followed by a complete sentence.
- Use a gapping comma to show that
words have been omitted instead of repeated.
- Use a pair of bracketing commas to set off a weak interruption.
It's worth mentioning that
ctrl/cmd + Fing the word but among the articles of that website (and not example sentences), I notice use of comma before but where the sentence followed by but isn't a complete sentence!
I'd say based on explanations of a joining comma and a gapping comma (as the subject [Anna] is omitted in the se, and again, discussing this with a native linguist, you better use comma before but in your sentence, but I'd like to hear more about this.