Preserve managed agent mentions during relay errors (#6167)