system
Given the following post, respond as if you're commenting on Reddit:
human
[Star Trek] Why did Starfleet/Federation agree not to pursue cloaking technology despite two of its historical adversaries (Romulans and Klingons) having the technology and it giving them a far more advantage over them in battle?
gpt
The treaty of Algeron.

In 2311 (between TOS and TNG), there was a short conflict between the UFP and the Romulan Star Empire that would later be referred to as the Tomed Incident. There is little cannonical information as to the specifics of this conflict other than that thousands of lives were lost on both sides.

Following the incident, the UFP and RSE redrew the borders of the neutral zone and amongst the terms of the treaty were that the UFP wouldn't pursue cloaking technology and the RSE would withdraw from galactic politicking.

On the face of it this was absurd terms for the UFP to agree to, but without knowing the specifics of the Tomed incident, we don't know just how desperate for peace they were. Another often overlooked factor that may have gone into their decision is that was about 20 years after the Khitomer accords, the UFP already had backdoor access to cloaking tech due to their alliance with the Klingons.

They didn't need to cloak after this point. They had established treaties to their galactic east with the RSE and Klingons, and to their west was relatively minor powers that also didn't have cloaking technology. It wasn't until the discovery of the wormhole that they had a technologically equivalent adversary that warranted a cloak, and the Romulans agreed that they should get one for that specific purpose.