The San Francisco 49ers and star left tackle Trent Williams agreed Monday to a two-year, $50 million contract that gives the team clarity about the future of one of its most important players before the NFL draft.