Hi. Well, have you been sick? You are coughing up what I use a really technical term for, gunk. Have you been ill? A lot of times, having yellow sputum (the real name for it) as you been means the immune system has been working to fight off an infection. Normally it would be white, the yellow color is the indicator of that. But I know I can have that after I've been sick. So, had you had any other symptoms lately? Maybe you have bronchitis? https://www.webmd.com/lung/cold-becomes-bronchitis (copy and paste into your browser). Are you a smoker? That is a time in which some will get that thicker mucus production as well and cough up phlegm.
TONSIL STONES!!! If the consistency of a cottage cheese curd. Size from a seed flake to a tic tac and get caught in throat. Then I say tonsil stones 100%. I know after a bad bug 15yrs ago I have a constant irritation and inflamed adenoid. When sick now even soda burns. I stopped drinking because of the pain. Stopped smoking too. It took 5 years and a young co-worker overhearing my conversation to get an answer as to what they were. Just you tube tonsil stone then go see your primary or dentist. Just do it quicker than I did because now my food comes out my nose sometimes.