If I understand well your point, you want to know whether 2 agents (say countries) can make transaction if they don't each gain from that trade.
In general, agents optimize some function, called the objective, with respect to some constraints, and 2 agents trading with each other will keep trading until both marginal utilities are equal (first-order conditions of the maximization problem). So to answer your question, an agent won't trade if that trade does not increase her utility. Having said that, in a world where there are some additional constraints (in addition of the budget constraints), or some externalities you can end-up in situations where agents trade while it is not strictly speaking beneficial for them. Specifically, there may be some rules that require some externalities to be strictly lower than some values, and that would yield to trade that indeed reduce the utility of the agent.
As an example, let's think about a country that is endowed with a technology which produce some output and some externalities, say pollution. Then without going through the specifics of such a model, if (once the equilibrium is reached) a new rule says that the amount of pollution that a country can produce needs to be lower than some value (which is assumed to be higher than what was originally produced), the country may need to trade with some other country (with higher cost, but lower pollution) to fulfill the requirement, then resulting in less utility than previously but the require amount of pollution.
To sum-up, in general (free market, with perfect competition, etc.) this won't be the case, but such situations could arise in the presence of additional rules (or externalities that need to be internalized or additional constraints to the maximization program).