West Coast dockworkers and their shipping line employers have agreed to federal mediation to help resolve a contract dispute that has been partly blamed for severe congestion at ports in Los Angeles and Long Beach.