The screenwriters union and Hollywood studios reached a surprise four-year tentative agreement after roughly three weeks of negotiation.