Heat oil and anchovies in a large skillet over medium-low. Cook, stirring with a wooden spoon, until anchovies are dissolved, 4 to 6 minutes. Stir in onions, thyme, salt, and pepper. Cover and cook, stirring occasionally, until onions are softened, 25 to 30 minutes. Uncover and continue to cook, stirring often, until liquid evaporates and onions are golden brown, 20 to 30 minutes. Transfer onions to a medium bowl to cool completely, about 30 minutes. Discard thyme sprigs.
Meanwhile, preheat oven to 400°F. Line 2 baking sheets with parchment paper. Transfer puff pastry to a lightly floured surface, and roll into a 20- x 10-inch rectangle (about 1/8-inch thick). Spread caramelized onions on 1 long half of dough rectangle, leaving a 1/4-inch border around edges. Top onions with olives. Fold empty dough half over onion filling. Cut dough crosswise into 32 (about 2/3-inch-wide, 5-inch-long) strips. Transfer strips to prepared baking sheets.
Working with 1 strip at a time, brush both sides lightly with egg. Twist and gently stretch strip to about 7 inches in length. Bake in preheated oven until golden brown, 20 to 25 minutes. Serve warm or transfer to a wire rack to cool completely, about 15 minutes.
Batons may be baked up to 4 hours ahead. Store at room temperature in an airtight container.