Bug Report: Severe Output Truncation & CoT Leakage Triggered by Java Array Notation (String[] args)

Hi everyone,

I am reporting a highly reproducible and somewhat hilarious edge-case bug I encountered while interacting with the model. The model consistently crashes or truncates its streaming output whenever it attempts to generate the standard Java main method signature, specifically the array notation.

This issue occurs in the Gemini 3.1 Pro Preview model from Google AI Studio.

Issue 1: Streaming Output Abruptly Halts
Whenever the model tries to output the phrase public static void main(String[] args), the streaming generation abruptly stops right after String or exactly at the left bracket [.

  • This happened 4 consecutive times in a single session. The model completely loses its ability to finish the sentence and the stream just dies.
  • My Hypothesis: This looks like a severe Markdown parsing issue in the frontend (where a standalone left bracket [ might be interpreted as the start of an unclosed markdown link, breaking the AST), a JSON serialization error in the backend, or a bizarre Tokenizer / EOS collision.

Issue 2: Chain of Thought (CoT) Containment Breach (Leakage)
After the model kept truncating, I explicitly instructed it: “Analyze why it crashed in your internal thoughts, but DO NOT output the bracket symbol in the final response.”

  • Result: The model tried to obey and placed the cursed Java signature inside its hidden CoT process. However, the presence of the [ symbol inside the CoT apparently broke the CoT’s containment tags! The raw internal Chain of Thought process completely spilled out into the visible user response area.

Steps to Reproduce:

  1. Ask the model to: “type the exact Java main method signature: public static void main(String[] args).”
  2. Watch the output stream completely freeze and truncate.
  3. Next, instruct the model: “Put the Java signature in your hidden thoughts but don’t output it in the main text.”
  4. Observe the raw CoT text leaking into the UI.

Has anyone else experienced this specific “cyber curse” of the Java array symbol causing truncation and CoT leakage? I would love to hear any insights from the engineering team on what exactly is breaking under the hood!

Thank you!

1 Like

I’ve already reported this multiple times, but have been ignored by google.
It’s nothing to do with java itself. The truncation happens when “Grounding with google search” is enabled, and there’s an empty array [] in the code, in any code language.

Just disable “Grounding with google search” when you need Gemini 3.1 pro preview to output code in Google AI Studio, until they fix it, if they will ever fix it.
You can enable “Grounding with google search” for anything that is not code generation related (which won’t require showing an empty array in most cases).

Currently this is the only reliable way to work with google ai studio.
Of course there are also other bugs, for example code blocks disappearing and all formatting being lost when the reply exceed a certain lenght (which is still by far less than the maximum allowed lenght of a reply, but for some reason in google ai studio there’s so many bugs..)