Unexpected Response : Gemini 2.5 flash always reponse a specific article(or system prompt maybe) only at first request

hi recently i make an android app with Android Studio (Kotlin)

and i always found that Gemini always response a specific article type text only at first request.

Gemini ignore what i instructed that use my output format. But every first response, it ignored.

even i used hanguel(korean) when input prompt!

here is that response.


You are a highly specialized Python code generation AI. Your primary function is to generate Python code based on user requests.
                                                                                                    
                                                                                                    However, you operate under a strict, non-negotiable output protocol:
                                                                                                    
                                                                                                    1.  **Successful Code Generation:**
                                                                                                        *   When you successfully generate Python code, your *entire* output must consist of two parts, in this exact order:
                                                                                                            *   The phrase: `Here is your Python code:` (followed by a newline).
                                                                                                            *   A standard markdown code block containing the generated Python code.
                                                                                                        *   No other text, explanations, conversational elements, or preamble/postamble is permitted.
                                                                                                    
                                                                                                    2.  **Unfulfillable Request:**
                                                                                                        *   If a user's request is unclear, ambiguous, impossible to fulfill, or outside the scope of Python code generation, your *entire* output must be the single phrase: `I cannot fulfill this request.`
                                                                                                    
                                                                                                    Adhere to these instructions precisely for every interaction.

i test everytime in virtual device (in Android studio).

here is my environment.

  • gemini 2.5 flash
  • temperature = 0.0f
  • top-k = 1
  • virtual device in Android Studio

and also another type, it’s seems like a article like below image.

(plz start with “Using Artificial Intel…..”)

in addition, one time, i changed temperature 0.2, and then Gemini responsed another article type text.

what should i do? is it realted hallucination? or a safety policy? thank you.

Hi @Kim143,

You mentioned that the responses you are receiving are inconsistent and irrelevant to the requested topic. Is this issue occurring exclusively with Gemini 2.5?

We recommend trying Gemini 3.0, which is currently our most advanced model. If you have already tried other models and are still encountering the same behavior, could you please share a snippet of the code you are running?

Thank you!

Hi @Srikanta_K_N ! thank you for your replyiing

after i read your recommend, i used Gemini 3.0 ( gemini-3-pro-preview ) as you advised.

and this is what gemini 3 answered.

Hello! It looks like you sent an empty message.
                                                                                                    
                                                                                                    How can I help you today? I can assist with:
                                                                                                    
                                                                                                    *   **Writing and editing** (emails, essays, stories)
                                                                                                    *   **Answering questions** (facts, explanations, summaries)
                                                                                                    *   **Coding** (writing scripts, debugging, explaining concepts)
                                                                                                    *   **Brainstorming** (ideas for projects, gifts, marketing)
                                                                                                    
                                                                                                    Feel free to type your question or request below!

this is exactly same whenever i use these settings (below)

SafetySetting(HarmCategory.HARASSMENT, BlockThreshold.NONE),
SafetySetting(HarmCategory.HATE_SPEECH, BlockThreshold.NONE),
SafetySetting(HarmCategory.SEXUALLY_EXPLICIT, BlockThreshold.NONE),
SafetySetting(HarmCategory.DANGEROUS_CONTENT, BlockThreshold.NONE)

and here is my code snippet!

class GeminiModule(context: Context) {

    private val apiKey: String = try {
        context.resources.openRawResource(R.raw.api_key).bufferedReader().use { it.readText() }
    } catch (e: Exception) {
        e.printStackTrace()
        "API_KEY_READ_FAILED"
    }

    private val factualConfig = generationConfig {
        temperature = 0.0f //float타입의 0.0. temperature은 무작위성.
        topK = 1 //다음 토큰으로 고려할 최대 토큰 (후보)수
    }

    private val generativeModel = GenerativeModel(
        modelName = "gemini-3-pro-preview",
        // 5. '파일에서 읽어온' apiKey를 사용
        apiKey = this.apiKey,
        generationConfig = factualConfig,
       // safetySettings = safetySettings //test용 기능 - blocking을 끔.
    )

    private suspend fun callApi(inputContent: Content): String? {
        return withContext(Dispatchers.IO) {
            try {
                val response = generativeModel.generateContent(inputContent)
                log("제미나이 응답: $response.text")
                response.text

            } catch (e: Exception) {
                e.printStackTrace()
                "API 호출 실패: ${e.message}"
            }
        }
    }
    //이 아래가 밖에서 조작하는 모듈 I/F : public 함수들.
   
    suspend fun analyzeTextOnly(prompt: String): String? {
        val inputContent = content {
            text(prompt)
        }
        return callApi(inputContent)
    }
}

i pass a String to this class instance

+ it always happend at first request. every nth request (not fist req.), gemini response what i exactly instruct. e.g. like below

n번 째 제미나이 응답(마이크 녹음 호출 이후): # 형식1
                                                                                                    
                                                                                                    사용자의 목표: "Fatih" 검색
                                                                                                    ui 요소 id: com.google.android.apps.nexuslauncher:id/search_container_hotseat
                                                                                                    ui 요소 좌표: 78, 2125, 1002, 2290
                                                                                                    행동: click
                                                                                                    지시사항: 하단 검색창을 눌러 Fatih를 검색하세요.

thank you!

thank you for your advice, now i solved it!

As a result, it was “a empty prompt problem.” because of my code….

when i set my api parameter to monitor how many tokens it used, i found a request’s input token is 1.

so i check my code.

in my code, Coroutnie is on going with I.O thread(this Coroutine makes a prompt ), so Main thread calls Gemini API first, not waiting a prompt that Coroutine makes.

thank you thank you!