Historical materialism is not vulgar and does not deny human agency. It posits that the march of history renders unto humanity a necessarily limited set of potential means, from which humans select to shape reality with — or, more eloquently, that:
"Men make their own history, but they do not make it as they please; they do not make it under self-selected circumstances, but under circumstances existing already, given and transmitted from the past."
— Karl Marx, The Eighteenth Brumaire of Louis Bonaparte, 1852
There are cases where humans have acted illogically, unpredictably, and even at odds with what is in their material interests, but never outside and against history.