The Gemini is not writing new codes

I’m hitting a wall with Gemini in Firebase Studio lately, and it’s super frustrating. It feels like ever since Gemini started explaining what it’s about to do (which is cool, theoretically!), the actual code changes just… aren’t happening.

It’ll show me the code it’s supposedly writing, even for simple stuff like renaming an element, but nothing changes in my actual files. It’s like it’s just putting on a show without applying anything.

Is anyone else running into this? It’s making development a real pain and kinda defeats the purpose of having Gemini help out. Any tips or fixes would be a lifesaver!

Thanks!

Yes.. Had the same issue. I think the team is fixing the problem.

2 Likes

Thanks, I will keep updating this topic, until they fix it.

1 Like

I am constantly getting “Sorry, I hit a snag. Please try again shortly.” error even for the simplest changes.

I tried to use the AI coder (in prototyper) in other projects and it works just fine for them. Thus, it is about only one project for me.

Are you getting the same error or do you encounter something else?

3 Likes

Same here. But hitting a snag is better than not knowing what is going on, just watching those 3 dots back and forth but nothing is happening. And, to the OP, all the time, I wait just to realize I actually need to tell it to execute what I just thought it did. It didn’t, was just playing back what it was SUPPOSED to be doing but isn’t.

2 Likes

@The_Lazy_Swiss , @bococan I had a similar issue in another project. It’s important to check the exact error you’re encountering. Click the dropdown next to the message “Sorry, I hit a snag. Please try again shortly” to see more details. Sometimes the error message isn’t very clear about the actual problem, but if you share it here, I’ll do my best to help you resolve it.

even the Prototyper knows its broken.

2 Likes

@kian_mansouri thank you very much for your reply and kind offer to help. My command is basically to create a new tab in the web app with this command:

Create a new tab named “Bookkeeping”.

The answer is this:

Sorry, I hit a snag. Please try again shortly.

[GoogleGenerativeAI Error]: Error fetching from https://monospace-pa.googleapis.com/v1/models/gemini-2.5-pro-preview-03-25:streamGenerateContent?alt=sse: [400 Bad Request] The input token count (1049106) exceeds the maximum number of tokens allowed (1048575).

I do no think the command itself (or the resulting code) exceeds the specified token amount. Any chance that you have had/solved a similar problem?

Hey there! Thanks so much for reaching out and sharing the issue you’re facing. I actually ran into the exact same problem with the App Prototyper throwing this error:

[GoogleGenerativeAI Error]: Error fetching from https://monospace-pa.googleapis.com/v1/models/gemini-2.5-pro-preview-03-25:streamGenerateContent?alt=sse: [400 Bad Request] The input token count (1049106) exceeds the maximum number of tokens allowed (1048575).

You’re totally right — it doesn’t seem like the command itself is the problem. The issue comes from how Firebase Studio saves all our conversation history in a file that grows over time. Once it goes over the model’s token limit, everything breaks.

Here’s how I solved it, and hopefully it helps you too:

:white_check_mark: Problem

Firebase Studio’s App Prototyper agent stores all chat history in a file: capra-context-state.json. Each time you send a prompt, the entire history is sent along — and if it’s too large, you get a token error like the one you saw.

:broom: Solution Summary

We trim down the stored conversation history to bring it below the token limit. The key is to keep the most important parts — the start (to preserve context) and the end (recent progress).

:ladder: Step-by-Step Fix

  1. Open your workspace in Firebase Studio

From [My Workspaces], open the one where the issue happens

Click Switch to Code

1. Open Terminal

Press `Ctrl + `` (backtick) or click Terminal at the bottom

1. Backup the JSON files (IMPORTANT)

Do this step-by-step in the terminal:

a. Create a backup folder:

mkdir -p /home/user/studio/context_backup/

b. Backup the context file:

cp /home/user/.idx/ai/capra-context-state.json /home/user/studio/context_backup/capra-context-state-$(date +%Y%m%d%H%M%S).json

c. Backup the thread file:

cp /home/user/.idx/ai/capra-thread.json /home/user/studio/context_backup/capra-thread-$(date +%Y%m%d%H%M%S).json

1. Add the backup folder to .gitignore

Open .gitignore and add:

prototyper

/context_backup
.gitignore

1. Open the context file

code /home/user/.idx/ai/capra-context-state.json

1. Format the JSON

In the editor: Right-click > Format Document

  1. Locate this section:
"app-prototyping-agent": {
"edit-app-agent": [ ... ]
}

1. Delete middle history entries

Keep:

The first ~20 conversations (optional number, worked for me)

The last ~10 conversations (also optional, tweak as needed)
Delete everything in between.

:warning: DO NOT delete outside the edit-app-agent: [ … ] array.

1. Save the file (Ctrl + S)

2. Switch back to Prototyper and test

Use a new prompt, not “Try Again” (as it uses the old cached version).

:brain: Reusable Prompt

If you want to ask someone else to help you clean the file, here’s a prompt you can send(

For the prompt, please mention that I copied the entire JSON file into a new file and gave that file to Google AI Studio Flash 2, then sent the prompt along with that file. ):
Blockquote

Please help clean this capra-context-state.json file.
Inside the field:


"app-prototyping-agent": {
"edit-app-agent": [ ... ]
}

Please keep the first 20 and last 10 conversation entries in the array. You can delete the middle ones to reduce token size. The numbers 20 and 10 are just what worked for me — feel free to adjust if needed. Just make sure only to delete inside the edit-app-agent array and keep the structure intact.

:fire_extinguisher: Still not working?

Try refreshing with Ctrl + R

Reset workspace from Firebase Studio

Recheck that history was reduced properly

:dna: Want to Restore Your Backup?

Use the terminal to copy the backup back:

cp /home/user/studio/context_backup/capra-context-state-.json /home/user/.idx/ai/capra-context-state.json

Replace <timestamp> with the actual timestamp from your backup file.

:left_speech_bubble: Share Your Fix!

If this worked for you, definitely reply and let others know. And don’t worry — the number of kept messages isn’t fixed, tweak it to your case.

Hope this helps! And fingers crossed Firebase adds context management tools soon :folded_hands:

@kian_mansouri, it worked like a charm, thank you!

The only thing I would like to add is this:

When I deleted the part of the context that I did not need anymore, I did not pay attention to where I cut it off. Apparently, I cut it off at a part where the next entry starts with “role”:“model”.

The model threw a different error this time about the first entry having to start with “role”:“user”. I deleted a couple more lines to make sure the section starts like this:

"app-prototyping-agent": {
"edit-app-agent": [ {"role":"user", ... } ]
}

I hope the addition helps to anyone else who might experience the same issue.

Cheers!

1 Like

In my case I had to get rid of all the conext. Here is a what I did. Works quite a lot better after it.

1 Like

@bococan, @bococan, Thank you both for your helps