Carmelo Anthony and La La are hashing out a temporary custody agreement in which she will get primary custody of their son ... TMZ has learned.

Sources close to the former couple tell us 10-year-old Kiyan will live with La La in NYC, but Melo has a totally open line of communication and will able to spend time with his son as much as he'd like.

We're told the 2 believe they can work out all the details without going to court ... it being done with their lawyers.

Both Carmelo and La La agree it's important they work out a structure for Kiyan so he's not whipsawed from place to place while they end their marriage.