Temporary workaround for error due to exceeding input token count (unofficial)

I tested it here…and the issue wasn’t solved yet :sob:

me too, i tried everything, i believe its because files got bigger, and there is no solutions

I checked the file sizes with Gemini’s support, but this didn’t solve the problem.

I tried creating a new project and uploading all the files to it, but unfortunately the same snag error appeared again. =/

I’ve tried practically every fix mentioned in this forum (pruning ~/.idx/ai, resetting the workspace, starting a brand-new workspace, etc.).

Steps I’ve taken so far

  1. Downloaded every file from my current project (just to have a backup).
  2. Created a brand-new workspace from scratch in Firebase Studio (no history, no threads).
  3. Tried to drag-and-drop the entire folder — Studio refused because the project was over 100 MB.
  4. Uploaded the same files manually in smaller batches (so each batch stayed under 100 MB).
  5. As soon as all files were in the workspace, the Prototyper started showing the same snag error, even though this was a newly created prototype.

So it looks like some file in my repo breaks the Prototyper (maybe the total size, maybe specific content), but I can’t figure out which one.

Things I already tried, without success

  • Pruned every JSON in ~/.idx/ai/ and ~/.idx/ai/threads/ (each < 120 KB).
  • Ran ⋮ → Reset workspace multiple times.
  • Deleted node_modules, .next/, .idx/ before importing.
  • Created an empty prototype and uploaded only the essential src/ files — same error.

I used the following command to check the files size, and this is the result:
show every JSON in ~/.idx/ai and its threads directory, largest firstdu -b ~/.idx/ai/.json ~/.idx/ai/threads/.json 2>/dev/null | sort -nr | head -n 20
11077 /home/user/.idx/ai/capra-context-state.json
5189 /home/user/.idx/ai/prototyper-thread.json
3457 /home/user/.idx/ai/prototyper-context-state.json

but the snag error is persistent


I tested some solutions with ChatGPT help and I get this answer:

find didn’t list anything, which means no single file in ~/.idx is larger than 500 kB. So how can the request still weigh in at 1 487 637 tokens?

The answer is that Prototyper also sweeps up your actual project files (the code and assets you imported) when it builds the prompt it sends to Gemini. If the repo you uploaded is ~100 MB, that alone can explode the token count—even if the .idx metadata is tiny.


Quick proof

Run this one‐liner to see the total size of everything under your workspace:

bash

CopyEdit

du -sh ~/*

You’ll probably see something like:

bash

CopyEdit

120M  /home/user/studio       # ← your project folder
12M   /home/user/.idx

Even 40 MB of source code (let alone 100 MB) can easily exceed 1 M tokens once JSON-encoded.

1 Like

did you find a solution ? here is what i discovered, the context is all about “prototyper-context-state.json” and “prototyper-thread.json” the solution worked in the beggining, but after other chating and editing with the protoyper it got stuck again, i tried to repeat the same solution for the second time, i cleared up the two files but it didn’t work, and when i re did the comand " timestamp=$(date +%Y%m%d%H%M%S);
mkdir -p “/home/user/studio/context_backup/” &&
cp “/home/user/.idx/ai/prototyper-context-state.json” “/home/user/studio/context_backup/prototyper-context-state-${timestamp}.json” &&
cp “/home/user/.idx/ai/prototyper-thread.json” “/home/user/studio/context_backup/prototyper-thread-${timestamp}.json”
" it showed the 2 files again and uncleared, so the changes i made didn’t apply, if they do then the prototyper will work again, when i edit something a notification pops up “ailed to save ‘prototyper-context-state.json’: File is read-only. Select ‘Overwrite’ to attempt to make it writeable.” and they give me options to click " overwrite" “save as” “revert”.

please keep me updated
this kind of major issue should have been fixed by firebase developpers long time ago, sorry but its not normal at all, there isn’t even an official documentation about it or a guide

What are your results for these 2 prompts (they will measure the file sizes)

largest 20 JSONs in ~/.idx/ai and its threads sub-folder

du -b ~/.idx/ai/.json ~/.idx/ai/threads/.json 2>/dev/null |
sort -nr | head -n 20

see which folders under ~/studio are eating space

du -h --max-depth=1 ~/studio | sort -hr | head

These are the mine results:

largest 20 JSONs in ~/.idx/ai and its threads sub-folderdu -b ~/.idx/ai/.json ~/.idx/ai/threads/.json 2>/dev/null |sort -nr | head -n 20

27980 /home/user/.idx/ai/threads/d355a896-9f6c-4bb2-a3c1-e2170d20637d.json
11077 /home/user/.idx/ai/capra-context-state.json
2980 /home/user/.idx/ai/prototyper-context-state.json
1791 /home/user/.idx/ai/prototyper-thread.json

see which folders under ~/studio are eating spacedu -h --max-depth=1 ~/studio | sort -hr | head

2.2G /home/user/studio
987M /home/user/studio/node_modules
720M /home/user/studio/.git
174M /home/user/studio/functions
62M /home/user/studio/.next
8.8M /home/user/studio/public
7.0M /home/user/studio/context_backup
3.4M /home/user/studio/src
28K /home/user/studio/.idx
8.0K /home/user/studio/.vscode

did you find a solution ? how is it going

no…none solution proposed by chatgpt is working.

1 Like

I’m also encountering the same input token limit issue with the App Prototyper Agent. Just commenting here to follow this thread and hopefully get updates on a new workaround or an official fix.

Have you tried this?

Someone should make an app for this. I made one but sadly remembered firebase apps are born mutated and die shortly after and then the prototyper kills itself. It’s really no use till google makes it a bit more stable. I think the should just let us build vanilla apps that would save most of the hassle, npm and node are serial murderers and other dependancies and politicians

For anyone still waiting on this, I fired up my project that had this issue. I asked if it was there (The AI) and it responded with this ands fixed the issue

" The error message you received is because I previously misconfigured your firebase.json file, leaving it in a state where Firebase didn’t know which part of your project to deploy.

I will now provide the correct configuration for firebase.json to explicitly point to your main Next.js application at the root of the project. This will resolve the deployment error."

it helped to delete the prototyper-thread.json in the ai / threads folder. mine seemed to be overflowing. i then restarted the app from firebase studio.

the prototyper is back again trying to fix errors and filling the file with current changes. i assume clearing / deleting the file now and again will help the stability of the build. in future builds i will be exporting the file to keep track of the changes i made before deleting it.

full path: user > .idx > ai > threads > prototyper-thread.json

me sale este error y no puedo arrglarlo

@Juan_Garcia_Osorio When you see the “Sorry, I hit a snag” message click the down “v” button to see the reason.

If the reason is your authentication token expired, you will need to reload the workspace to fetch a new token. The token is suppose to refresh while you are using Firebase Studio, but there may be a bug in some scenarios preventing the refresh.

@jamesor @Tom

please can you help me out i have done everything on this topic but still getting the error

[GoogleGenerativeAI Error]: Error fetching from https://monospace-pa.googleapis.com/v1/models/gemini-2.5-pro:streamGenerateContent?alt=sse: [400 Bad Request] The input token count (2090442) exceeds the maximum number of tokens allowed (1048576).
i even imported to a new project same thing

You are receiving a different error than an expired token. Your error is because your input is too large. This is either because what you are pasting into the prompt is too large or your context history is too big. Read through this thread to find techniques on clearing your context if it’s not your prompt size.

Above thread fails to solve the problem of maximum token limit. Please help!

I’m also back in the same boat and have tried the preivous fix in my thread Firebase Studio Token Exceeding in Prototyper - General - Firebase Studio Community and also the How-to Enabling Prototyper on Existing Project + Prototyper Full Context Clear but I can’t tell the Prototyper anything after creating the .md files. Even if I hit clear, restart, update my .gitignore, restart, etc…etc. I’m still getting the [GoogleGenerativeAI Error]: Error fetching from ``https://monospace-pa.googleapis.com/v1/models/gemini-2.5-pro:streamGenerateContent?alt=sse:`` [400 Bad Request] The input token count (4354085) exceeds the maximum number of tokens allowed (1048576). I have also used the node app (token analyzer) which shows I’m under 200K of tokens after cleaning up files and still running into this token error. Any ideas?