Should I keep both cannons or trade one?
These answers restate the rules implemented by our open-source engine, which follows the WXF laws for movement, checkmate and both repetition rulings: a side that forces a repetition by perpetual check or perpetual chase loses rather than drawing. The chase half has not been validated against the official casebook. Where an answer refers to a specific position, that position lives on the linked reference page, where the build verifies it before publishing.
Direct answer
Keep both while the board is full, particularly if you are the attacker: two cannons can stack into 重炮, which needs no other support, and each can screen for the other. Trade one heading into an endgame, where cannons fade and the horse you get in return is gaining value.
The attacking case for two
Two cannons are more than twice one cannon, because each solves the other's screen problem. Against a general on an open central file, a second cannon can convert a positional bind into a forced mate in a single move.
If your opponent has both cannons and your general's file is clear, that is a concrete danger worth spending a move on.
The endgame case for trading
A cannon weakens with every exchange, so its value is highest now and lower later. Trading a cannon for a horse while the board is still full is buying a piece that is about to appreciate with one that is about to depreciate.
Related questions
Is one cannon and one horse a good pair?
Very — it is the 馬後炮 pair, and it forces mate against a bare general.
Should I trade cannons when defending?
Usually yes. It removes 重炮 from the position entirely.