Diplomacy in RTW is retarded and backwards. It is all hardcoded and modders just have to deal with it.

Most of the time when you get a peace treaty the AI will immediately attack you again.