A failed star and an ammonia trail could reveal how some giant exoplanets form