There is a system that transports protein fragments to the cell surface and “presents” them to the immune cells: https://en.m.wikipedia.org/wiki/Antigen_presentation
In addition, B and T cells only detect fragments on the surface of active Dendric cells. Dendric cells become active in response to alternate and less specific indications of infection such as an unusually high amount of mRNA translation or families of protein that occur only in bacteria and viruses.