As so often, it depends. This is hardly exhaustive, but some variables:
Opponents. Who are you playing against? A notorious techer, like Mansa Musa or (less markedly) Willem or Pericles, will trade for much longer. Others will become filled with fear much more quickly (e.g. Alexander, Pacal). If you can, trade with the latter group first and the former only when your past trading partners become reluctant. An AI like Mansa can run away in tech if you're not careful.
Relations. Who are you trading with? Some AI will trade at cautious, others won't. Some need to be at friendly (Toku, I guess?). More importantly, will trading with another AI's worst enemy bump your relations down a notch? Or will another AI trade your hard earned tech the moment you give it to them? (freaking Mansa.)
Short-term benefit to player. Obviously you're going to need fishing sooner rather than later, and even meditation/poly give you early access to AP buildings. Other techs can be less pressing. How soon do you really need compass, or optics? Can theology be delayed? Do you need longbows immediately? What good has divine right ever done anyone? (Apart from being trade bait...).
Long-term benefit to player. There are a number of techs you should retain for as long as possible, or at least until another trade-happy AI has broken your monopoly. Philosophy is a big one, when you're the first to get it through a bulb. AIs tend to ignore the religious techs once the religion is founded, and since philosophy is a prerequisite of lib. you've really no good reason to trade it away.
Hold on to military techs if you're planning to war any time soon (except, perhaps, if another smaller AI looks to be folding to a larger AI). Wonder techs should be retained if you want to build said wonder. If you want to build the Great Library, hold on to aesthetics as long as you dare so that you get a good head start on literature. Conversely, the AI are remarkably reluctant to trade away a wonder tech if they're building that wonder, so you can trade (e.g.) music to one AI and not have to worry about the other six getting it in the next turn, which makes siphoning gold across multiple turns a little easier. If you're really savvy, you can also pick which AI builds a wonder through selective trading (give up music to an AI situated at the other end of the world rather than on your door-step. Let an unpopular AI build the UN, so that they never become general secretary... etc.).
Vassals. If you win via domination or conquest, then presumably you pick up some vassals along the way. Think of vassals as a means to both (1) double-up on your research and (2) circumvent trade caps. Ideally, you want to have at least one good researching vassal because by that stage you can trade exclusively with them any time you please. I generally start to hit my trade caps shortly after rifling, but if you have a vassal this really doesn't matter. They still have to trade with you.
In short, trade sensibly and don't give away the good stuff for junk; you will hit your trade caps because the human virtually has to trade to keep up, but the tipping point tends to come post-lib. and once you've gotten lib. you really should be in a position to vassal one or two AIs, take them as trading partners, and win the game.