End-to-end modeling (E2E) of automatic speech recognition (ASR) blends allthe components of a traditional speech recognition system into a unified model.Although it simplifies training and decoding pipelines, the unified model ishard to adapt when mismatch exists between training and test data. In thiswork, we focus on contextual speech recognition, which is particularlychallenging for E2E models because it introduces significant mismatch betweentraining and test data. To improve the performance in the presence of complexcontextual information, we propose to use class-based language models(CLM) thatcan populate the classes with contextdependent information in real-time. Toenable this approach to scale to a large number of class members and minimizesearch errors, we propose a token passing decoder with efficient tokenrecombination for E2E systems for the first time. We evaluate the proposedsystem on general and contextual ASR, and achieve relative 62% Word ErrorRate(WER) reduction for contextual ASR without hurting performance for generalASR. We show that the proposed method performs well without modification of thedecoding hyper-parameters across tasks, making it a general solution for E2EASR.