Sails decides that from the request. You can find it in the source code . I've copied and commented the interesting part for you:
// True, if the request has a xhr polling origin. (via socket)
req.wantsJSON = req.xhr;
// True, if the above was false (or null) and the origin not only accepts html.
// See HTTP header field 'Accept'
req.wantsJSON = req.wantsJSON || !req.explicitlyAcceptsHTML;
// True, if everything above was false (or null) and the origins content type
// is json and the header field 'Accept' is set.
// See HTTP header field 'Content-type'
req.wantsJSON = req.wantsJSON || (req.is('json') && req.get('Accept'));