One of the things that's usually attractive about capitalism is that it is, in a sense, the default. Absent a government saying otherwise, two individuals or businesses or even countries will tend towards capitalism in their relations. But absent a government saying otherwise, slavery also arises, in many places and times in history.
What changed to make people say "Hey, we're failing to treat slaves as economic agents"? It may be the case that on paper, slavery was not economically viable ever - but it was absolutely profitable and desirable in practice. (That may be the disconnect; I'm using "economically viable" in a practical sense.)
The question of who is an economic agent is exogenous to capitalism.
What changed to make people say "Hey, we're failing to treat slaves as economic agents"?
In the US, a bunch of religious crazies decided to force their biblical interpretations on everyone else. For a while they used politics and small scale warfare (e.g. running around ad night and chopping people's heads off) to push their morals on everyone else, on slavery and other issues like drinking and polygamy. Eventually the limited wars erupted into a total war for dominance, which they won.
I'm less familiar with European history so I won't speak about that.
In the way capitalism arose from pillage & plunder.
Even way before the Industrial Revolution.
The navies protected the (taxable) commerce from further pillage & plunder.
But the only ones that could afford to build any ships at all were usually the monarchs whom had already largely pillaged and plundered the wealth of their subjects.
Capitalism at this complete a level of wealth concentration reveals its eventual destructive effect on free enterprise.
Due to the extreme wealth inequality ships could justify cargoes of volunteers who would virtually pay to live as somewhat of a slave somewhere else.
Eventually it was only a matter of greed whether a particular voyage would contribute to a more advantageous outcome when choosing either physical or financial bondage for their cargoes of slaves.
When the viewpoint of the capital owners is so far removed from that of the lowest-level subjects, the difficulty for them to respect the (finer?) differences between physical vs. financial bondage of their servants in the 18th & 19th centuries evolves into the blurring of the distinction between financial bondage vs. financial empowerment of their employees in the 20th & 21st centuries.
Simply depending on where the powerful draw the line when greed is involved.
When the money must make money even under adverse conditions, the result of unbridled capitalism tends toward slavery of some form or another.
Depending on your point of view, I guess.
This may be true, but it's completely unrelated to the point I made.
Slavery is only economically viable if you don't treat the slaves as economic agents. At the time when slavery was being debated, virtually no one actually made this argument because it was patently ridiculous.
In fact, the phrase "the dismal science" was coined by a slavery supporter to criticize the economists who opposed slavery. Slavery proponents were actually anti-capitalists who argued that slavery was better for slave and master alike - they favored hierarchical relations rather than exchanges based on mutual agreement. I know Moldbug has been shunned from society for advocating it, but you should read Carlyle if you want to understand history.
It's true that if you don't treat foreigners as economic agents, then economics does in fact suggest treating them as an exploitable resource as well. In fact, if you take that premise, we should probably enslave them rather than just pass protectionist laws against them.