Gemini has serious problems with ',' ")" "/" "//" "\" does not know how to fix any error of this type
What happened?
Gemini has serious problems with ',' ")" "/" "//" "" and doesn't know how to fix any errors of this type.
There was a case where you built new, more batch-style code in C# and had serious problems properly closing the corresponding types mentioned above. GEMINI GAVE UP AND FINALLY reverted the changes.
What did you expect to happen?
that controls the patterns well.
Client information
CLI Version 0.1.17-nightly.250809.f35921a7 Model gemini-2.5-pro Sandbox no sandbox OS win32 Auth Method gemini-api-key
Login information
No response
Anything else we need to know?
No response
Hi, thanks for filing this. I’d like to gather a bit more concrete data so it becomes actionable, and share some provisional hypotheses/workarounds.
Restating the Issue: Gemini (model: gemini-2.5-pro via CLI 0.1.17-nightly.250809.f35921a7 on Windows) often produces malformed C# code where delimiters / punctuation (',' ')' '/' '//' '""') end up unbalanced or misplaced, and eventually you had to revert the changes.
Clarifying Questions:
Could you post two minimal examples (prompt + the exact malformed C# output)? Are the failures compile-time (C# compiler errors) or just IDE formatting / syntax highlighting warnings? Did you already constrain the prompt with fenced code blocks (```csharp) or directives like “Only return compilable C# code”? Which constructs fail most (e.g., using statements, generics, string interpolation, verbatim strings, comments)? Does it happen only on longer generations (hundreds of lines) or even on short snippets? Are you changing temperature / top-p / top-k from defaults? (Higher randomness can break balanced delimiters.) Suggested Reproduction Steps (so maintainers can verify):
Provide the exact CLI invocation you used (e.g. gemini generate -m gemini-2.5-pro -p prompt.txt --temperature=0.7). Try this minimal prompt and share raw output if it breaks: “Generate a C# method that parses a CSV line safely, returning a (bool success, string[] fields). Return only a fenced code block with language csharp and valid compilable code.” Re-run the same with temperature=0 (and optionally --top-p=0.1) to see if determinism fixes it. Compile locally: csc /langversion:latest Test.cs and attach compiler errors. Wrap prompt in a JSON request pattern: “Respond in JSON with a single key code containing only the full C# source” to test whether escaping enforcement changes behavior. Potential Causes:
Elevated randomness (temperature/top-p) disrupting delimiter closure. Multi-phase narrative + code output causing fence or parenthesis drift. Post-processing in the CLI affecting quotation or newline handling (especially CRLF normalization on Windows). Incorrect escaping in strings containing backslashes when not using verbatim @"..." strings or C# 11 raw strings. Truncated streaming output leading to incomplete blocks. Interim Workarounds / Things to Try:
Deterministic generation: set temperature=0. Hard prompt constraints: “Return ONLY one fenced block: csharp ... . The code MUST compile without edits. Do not include commentary outside the code block.” Limit code size: “Limit code to under 80 lines.” Decompose large tasks: first generate interface / signatures, then ask for implementations incrementally. Automated refinement loop: (a) generate, (b) save to file, (c) compile, (d) feed back compiler errors: “Fix only these errors: … Provide full corrected file.” For quoting / slash issues: explicitly request verbatim strings @"..." or C# 11 raw string literals. Strip narrative by instructing: “No narrative, no markdown except the single code fence.” Additional Useful Data: If available, a request/trace id from the failing generations would help maintainers correlate logs.
Next Step: If you can provide 1–2 broken output samples + compiler errors + the exact CLI command, I can attempt a reproducible case and propose a tighter prompt or confirm if this looks like a decoding/regression issue worth escalating.
Happy to help further—just send the samples. Thanks!
Unfortunately, the Gemini model has issues with escaping code especially when its dealing with multiple levels of escaping (like when it calls the replace tool). Will close this as a general model quality issue.