Gemini output swallows square bracket
Before submitting your bug report
- [X] I believe this is a bug. I'll try to join the Continue Discord for questions
- [X] I'm not able to find an open issue that reports the same bug
- [X] I've seen the troubleshooting guide on the Continue Docs
Relevant environment info
- OS:
- Continue version:
- IDE version:
- Model:
- config.json:
Description
One square bracket is swallowed with gemini models.
To reproduce
No response
Log output
No response
This issue hasn't been updated in 90 days and will be closed after an additional 10 days without activity. If it's still important, please leave a comment and share any new information that would help us address the issue.
Same issue here. IT keeps ignoring one ]. I thought it was a continue problem but i saw it happen once with Cline too. And i was using Gemini pro on that one.
When i use gemini web,i have same issue,i lost [] in code block.
I am consistently having this issue with about 20% of ending square brackets. I'm working in TypeScript and react native. I have the problem with Gemini 2.0 Flash, Flash thinking, Pro, and Gemini 2.5 Pro. The problem has persisted across multiple versions of Continue (at least Jetbrains 1.0.5 to 1.0.10). It occurs on both VScode and Webstorm.
Same issue here. IT keeps ignoring one ]. I thought it was a continue problem but i saw it happen once with Cline too. And i was using Gemini pro on that one.
I wonder if there is a way to mitigate it since you had seen it only once with Cline. Do you use Cline as frequently as Continue? Are you still having the issue in both?
When i use gemini web,i have same issue,i lost [] in code block.
I wonder if this is the same issue or not. My use is only losing ending square brackets, both with empty and non-empty arrays. Your issue seems to be described here. https://support.google.com/gemini/thread/329152739/gemini-outputting-empty-square-brackets-is-broken?hl=en
My guess is that the issues are related, but not identical.
@mubiru-simeon @wilksu @robertpiosik Are you still having the issue with the square brackets? Have any of you found a workaround? Also see my questions above.
Relevant environment info where the issue has occurred
- OS: Windows 10 & 11
- Continue version: At least Jetbrains 1.0.5 to 1.0.10, maybe earlier
- IDE version: Webstorm 2024.3.5
- Model: Gemini 2.0 Thinking, Gemini 2.5 Pro, and more
- config:
{ "models": [ { "title": "Gemini 2.0 Flash Thinking", "model": "gemini-2.0-flash-thinking-exp-01-21", "contextLength": 2000000, "apiKey": "redacted", "provider": "gemini" }, { "title": "Gemini 2.0 Flash", "model": "gemini-2.0-flash", "contextLength": 2000000, "apiKey": "redacted", "provider": "gemini" }, { "title": "Gemini 2.5 Pro", "model": "gemini-2.5-pro-exp-03-25", "contextLength": 2000000, "apiKey": "redacted", "provider": "gemini", "completionOptions": { "reasoning": true, "maxTokens": 64000 } }, ], "tabAutocompleteModel": { "title": "Codestral", "provider": "mistral", "model": "codestral-latest", "apiKey": "redacted" }, "customCommands": [ { "name": "test", "prompt": "{{{ input }}}\n\nWrite a comprehensive set of unit tests for the selected code. It should setup, run tests that check for correctness including important edge cases, and teardown. Ensure that the tests are complete and sophisticated. Give the tests just as chat output, don't edit any file.", "description": "Write unit tests for highlighted code" } ], "contextProviders": [ { "name": "code", "params": {} }, { "name": "docs", "params": {} }, { "name": "diff", "params": {} }, { "name": "terminal", "params": {} }, { "name": "problems", "params": {} }, { "name": "folder", "params": {} }, { "name": "codebase", "params": {} }, { "name": "repo-map", "params": {} } ], "slashCommands": [ { "name": "share", "description": "Export the current chat session to markdown" }, { "name": "cmd", "description": "Generate a shell command" }, { "name": "commit", "description": "Generate a git commit message" } ], "reranker": { "name": "voyage", "params": { "model": "rerank-2", "apiKey": "redacted" } }, "embeddingsProvider": { "provider": "voyage", "model": "voyage-code-3", "apiKey": "redacted" }, "docs": [ { "startUrl": "redacted", "title": "Open Event Server Docs Snippets", "faviconUrl": "" }, { "startUrl": "https://github.com/fossasia/open-event-frontend/tree/development/", "title": "Open Event Frontend Docs", "faviconUrl": "" } ] }
Description Ending square bracket is sometimes missing with some Gemini models.
To reproduce
I know there's got to be many ways to reproduce it, and this method didn't work for Gemini 2.0 Flash, but it did work for some of the others.
- Open new conversation in the Continue extension and submit the following prompt to Gemini 2.0 Flash Thinking or Gemini 2.5 Pro.
Please generate a beginning coder demo in React Native with expo using TypeScript that includes multiple arrays. This will be a learning tool. Make it long and complex and in one file and I'll split it into code blocks later.
- Examine the output with your IDE or manually and at least 1 ending square bracket should be missing. If it's not missing, repeat step 1 then check again. I never had to repeat more than once with this prompt.
Log output
The only log output with timestamps close to when I did this was in the prompt.log. There was nothing in core.log for the timeframe and nothing related in idea.log.
##### Completion options #####
{
"contextLength": 2000000,
"model": "gemini-2.0-flash-thinking-exp-01-21",
"maxTokens": 8192
}
##### Request options #####
{}
##### Prompt #####
<system>
<important_rules>
Always include the language and file name in the info string when you write code blocks. If you are editing "src/main.py" for example, your code block should start with '```python src/main.py'.
</important_rules>
<user>
Please generate a beginning coder demo in React Native with expo using TypeScript that includes multiple arrays. This will be a learning tool. Make it long and complex and in one file and I'll split it into code blocks later.
Completion:
[object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object]
@Patrick-Erichsen Any chance you could take another look at this gemini square bracket issue? I added a more complete bug report to the comment above this.
Since Gemini 2.5 Pro came out, it's the best model for my use case, and the missing ending square brackets are really annoying.
I've seen recommendations to use temp=0.1 for coding with Gemini. I've tried it, but it doesn't help. Now, I'm thinking about pipelining the gemini's output to a smaller LLM just to fix brackets.
Hey @spottenn , thanks for the detailed writeup here. Not sure how soon we'll be able to prioritize unfortunately but added a good first issue label in the hopes someone in the community has some bandwidth.
I'm still a little confused as to what an example of the bug looks like here, any case you could share some exact copy/pasted text from a sample response where this is happening?
I've seen recommendations to use temp=0.1 for coding with Gemini. I've tried it, but it doesn't help. Now, I'm thinking about pipelining the gemini's output to a smaller LLM just to fix brackets.
Yeah, I tried a really low temperature too, and it didn't seem to help. I also didn't love the way that the low temp changed the code.
@ru-sh Let me know if you figure out a good way to do that. I wonder if we might be able to use the apply model if we give it a correct system prompt.
I'm still a little confused as to what an example of the bug looks like here, any case you could share some exact copy/pasted text from a sample response where this is happening?
Sure, here it is below in a real conversation I was having. It didn't format correctly copying it from the IDE, but the message and the response are there. The error occurs in line 17 of the response, backgroundColors?: string[;.
It's so weird because Gemini 2.5 Pro never has any other syntax errors for me, but this one consistently shows up.
My Message:
SelectableButton.tsx (1-96)
import * as React from "react";
import { Text, StyleSheet, Pressable } from "react-native";
import { Image } from "expo-image";
import { LinearGradient } from "expo-linear-gradient";
import IconClose from "../assets/icon-close.svg"
import IconSet from "./IconSet";
export type SelectableButtonType = {
label: string;
selected: boolean;
onPress?: () => void;
dismissable?: boolean;
onDismiss?: () => void
/** Optional fixed width/size for standalone use outside of group */
style?: object;
};
const SelectableButton = ({
selected = false,
label = "label",
onPress,
dismissable = false,
onDismiss,
style = {}
}: SelectableButtonType) => {
// Determine if gradient should be used (when selected or dismissible)
const useGradient = selected || dismissable;
return (
<Pressable
onPress={onPress}
style={[styles.buttonWrapper, style]}
android_ripple={{ color: 'rgba(0,0,0,0.1)' }}
>
{({ pressed }) => (
<LinearGradient
// Define start and end points for a horizontal gradient
start={{ x: 0, y: 0.5 }}
end={{ x: 1, y: 0.5 }}
style={[
styles.root,
!useGradient && styles.selectableButtonContainerVar,
pressed && styles.pressed
]}
locations={[0, 1]}
// Use gradient colors for selected or dismissible buttons
colors={useGradient ? ["#278a75", "#39b88d"] : ["#f6f8f7", "#f6f8f7"]}
>
<Text style={[styles.label, !useGradient && styles.labelTextVar]}>
{label}
</Text>
{dismissable && (
<Pressable onPress={onDismiss} hitSlop={10}>
<IconClose width={10} height={10} />
</Pressable>
)}
</LinearGradient>
)}
</Pressable>
);
};
const styles = StyleSheet.create({
buttonWrapper: {
flexGrow: 1
},
selectableButtonContainerVar: {
backgroundColor: "#f6f8f7",
},
labelTextVar: {
color: "#a7a7a7",
},
label: {
fontSize: 10,
fontFamily: "Poppins-Regular",
color: "#fff",
textAlign: "left",
},
root: {
borderRadius: 12,
overflow: "hidden",
flexDirection: "row",
alignItems: "center",
justifyContent: "center",
padding: 12,
gap: 10,
minWidth: 98,
backgroundColor: "transparent",
},
pressed: {
opacity: 0.9,
}
});
export default SelectableButton;
Add an optional property for background colors.
Gemini 2.5 Pro Response:
import * as React from "react";
import { Text, StyleSheet, Pressable } from "react-native";
import { Image } from "expo-image";
import { LinearGradient } from "expo-linear-gradient";
import IconClose from "../assets/icon-close.svg"
import IconSet from "./IconSet";
export type SelectableButtonType = {
label: string;
selected: boolean;
onPress?: () => void;
dismissable?: boolean;
onDismiss?: () => void
/** Optional fixed width/size for standalone use outside of group */
style?: object;
/** Optional background colors for the button. If provided, overrides default selected/unselected colors. Expects an array of strings (e.g., ['#ff0000', '#00ff00'] for gradient, or ['#eeeeee'] for solid). */
backgroundColors?: string[;
};
const SelectableButton = ({
selected = false,
label = "label",
onPress,
dismissable = false,
onDismiss,
style = {},
backgroundColors
}: SelectableButtonType) => {
// Determine if gradient should be used (when selected or dismissible, or custom colors provided)
const hasCustomBackground = backgroundColors && backgroundColors.length > 0;
const useGradient = selected || dismissable;
// Determine the colors to use
let colors: string[];
if (hasCustomBackground) {
// If one color is provided for custom background, duplicate it for solid LinearGradient
colors = backgroundColors.length === 1 ? [backgroundColors[0], backgroundColors[0]] : backgroundColors;
} else if (useGradient) {
// Default selected/dismissable gradient
colors = ["#278a75", "#39b88d"];
} else {
// Default unselected solid color
colors = ["#f6f8f7", "#f6f8f7"];
}
// Determine if the unselected text style should be applied
// Apply grey text only if NOT selected, NOT dismissable, AND NO custom background is set
const applyUnselectedTextStyle = !selected && !dismissable && !hasCustomBackground;
return (
<Pressable
onPress={onPress}
style={[styles.buttonWrapper, style]}
android_ripple={{ color: 'rgba(0,0,0,0.1)' }}
>
{({ pressed }) => (
<LinearGradient
// Define start and end points for a horizontal gradient
start={{ x: 0, y: 0.5 }}
end={{ x: 1, y: 0.5 }}
style={[
styles.root,
// Apply specific style only if default unselected colors are used
!useGradient && !hasCustomBackground && styles.selectableButtonContainerVar,
pressed && styles.pressed
]}
locations={colors.length > 1 ? [0, 1] : undefined} // Only set locations for actual gradients
colors={colors}
>
<Text style={[styles.label, applyUnselectedTextStyle && styles.labelTextVar]}>
{label}
</Text>
{dismissable && (
<Pressable onPress={onDismiss} hitSlop={10}>
<IconClose width={10} height={10} />
</Pressable>
)}
</LinearGradient>
)}
</Pressable>
);
};
const styles = StyleSheet.create({
buttonWrapper: {
flexGrow: 1
},
// Style specifically for the default unselected state
selectableButtonContainerVar: {
backgroundColor: "#f6f8f7", // This might be redundant now with LinearGradient handling colors
},
labelTextVar: {
color: "#a7a7a7",
},
label: {
fontSize: 10,
fontFamily: "Poppins-Regular",
color: "#fff", // Default text color (for selected/custom background)
textAlign: "left",
},
root: {
borderRadius: 12,
overflow: "hidden",
flexDirection: "row",
alignItems: "center",
justifyContent: "center",
padding: 12,
gap: 10,
minWidth: 98,
backgroundColor: "transparent", // Let LinearGradient handle the background
},
pressed: {
opacity: 0.9,
}
});
export default SelectableButton;
@spottenn we recently shipped the ability to customize the apply template if you want to give that a try: https://docs.continue.dev/customize/model-roles/apply#prompt-templating
If that works a band-aid solution might be just noting this as an option in the docs.
Thanks for getting back! I bet that will work! I'm working on some non-coding stuff for the next few days, but I will test it and let you know, hopefully by the end of the week.
This issue hasn't been updated in 90 days and will be closed after an additional 10 days without activity. If it's still important, please leave a comment and share any new information that would help us address the issue.
@spottenn we recently shipped the ability to customize the apply template if you want to give that a try: https://docs.continue.dev/customize/model-roles/apply#prompt-templating
If that works a band-aid solution might be just noting this as an option in the docs.
I'm having this issue as well. Gemini constantly breaks the code by deleting closing square brackets, then notices it, tries to fix it, and breaks something else.
Modifying the apply prompt template does not seem to help.
@uinstinct - another one that would be good to pick up next week.
Triaging issues and linking some that could be similar.
| Related Issues |
|---|
| #6305: Error when using Gemini model |
| #6473: Error handling model response |
| #6401: Error handling model response |
The issue still persists for me with Gemini 2.5 Pro or Flash in Apply-Mode via the Gemini-API from Google AI Studio.
']' or '}' are missing in the final response on a regular basis. Like every 100 Lines of code, there is one missing.
The problem does not appear on newly generated code in chat mode, but only when applying model is used. Therefore I also got no problems when interacting with Google AI Studio directly.
Using Visual Studio Code on Ubuntu 24.04 LTS in a Flatpak.
The problem is kind of annoying, when half of the changes applied need to be fixed manually and even on lines that should not change at all, there are newly created syntax-errors, messing with code highlighting.
@cspiegel-zepf I got the same error on Mac Os (26.0.1 (25A362) with Continue 1.2.7. The models work as expected within the Google AI Studio. Unfortunately, Continue still has a lack of support for Gemini Models in this regard.
Potential fix: https://github.com/continuedev/continue/pull/8153
:tada: This issue has been resolved in version 1.27.0 :tada:
The release is available on:
Your semantic-release bot :package::rocket: