hammer out something
— phrasal verb with hammer us/ˈhæm·ər/verb [ I/T ]
to arrive at an agreement or solution after a lot of argument or discussion:
Eventually, a deal was hammered out between the government and the opposition to hold new elections.