Persistent hallucination by gemini 3.5 flash using gemini-api

Gemini-api generates random set of results with meaningful sentences which are out of context for the input prompt (AI hallucination).
Here is the scenario under which this problem occurs :
I am fetching results from gemini-api (gemini 3.5 flash) using from my typescript react application. The first input to the api gives this hallucinated results, the subsequent results are valid results for the input prompt. So this problem persist as whenever I make changes or reload the application the first result from the api again gives hallucinated results.
Also it needs to be mentioned is that, passing a simple string to the api works fine, the bug only occurs only when concatenated string is passed in the api (For my application the string is mathfield value string generated using mathlive and a starter string (like : "Give me a brief breakdown of the following equation : " + math equation) to make the prompt as a complete question).