Federal immigration agents detained an 18-year-old New Haven man Tuesday shortly after he left a hearing in his criminal case at the state courthouse on Elm Street — boxing in the car he was riding in, breaking a window, and pulling him out, according to the driver.