Many have raised alarms about the potential for artificial intelligence to displace jobs in the years ahead, but it’s already causing upheaval in one industry where workers once seemed invincible: tech. A small but growing number of tech firms have cited AI as a reason for laying off workers and rethinking new hires in recent months, as Silicon Valley races to adapt to rapid advances in the technology being developed in its own backyard. Chegg, an education technology company, disclosed in a regulatory filing last month that it was cutting 4% of its workforce, or about 80 employees, “to better...