The reality is that it is 'impossible' because, without 'impossible' checks, the AI will literally bargain with another AI at absurd levels to make trades. It's profoundly hard to edge the line between flexible and 'abuseable' because, at some exorbitant point, an AI must say 'no' not just to humans, but also to other AI (otherwise you'll start seeing more 'phony wars').
G
I've thought for a while that the way the AI resolves deals with other AI players ("equalizes" them, at least from what I can tell reading the code) is a problematic mechanic, because if one player greatly overvalues or undervalues an item, always meeting at the halfway point is not a realistic or strategic way of handling this, and it's probably causing the bargaining at absurd levels.
I recognize the amount of work required for a rewrite (and you've done a lot already) - but my thoughts are that the AI should have a limit on how much they're willing to pay, at least for certain items like wars and cities. AIs often value third party wars greatly and pay huge amounts for it. This was a
while back, but in 2018 I was able to accept a bribe from Arabia, who had a huge military and wasn't at war with anyone, to declare war on their weak neighbor (as in "borders touching") - and in exchange they gave me all of their Gold and all of their GPT minus 2 - with thousands of deal value left to spare. This was highly abuseable, and after destroying Austria I turned my attentions on Arabia itself. I see that a recent hotfix has lowered the value of wars, but I nevertheless think the AI should have some kind of strategic limit to prevent this kind of absurd bargaining. Perhaps it could be calculated based on the AI's existing resources, sort of like peace treaties.
Also, someone else reported that it was possible to obtain small amounts of Gold from the AI for free by repeatedly making trades, which suggests to me that they're isn't a check on zero-value trades - has that been fixed?
In regards to phony wars, I'm working on this issue myself in the diplomacy AI.