Government officials signed a peace agreement in May with militants in Swat to try to end months of fighting that began in late 2007 .