An internal error occurred. Failed to generate content / AI Studio

Bug Description
In SOME specific old chats in Google AI Studio, any attempt to generate a response results in:

  • “An internal error occurred”
  • Warning banner: “Failed to generate content, please try again”

The chats are visible (I can scroll history, see all messages), but generation is permanently broken. New chats work normally (even with images uploaded now).

What I’ve noticed

This only seems to affect older chats with some attachments in it (pdf, img, txt e.t.c) — and it doesn’t matter if I deleted those attachments or not. Those chats containing pure text are fine.

What I’ve Already Tried (all unsuccessful)

  • All browsers: Chrome, Safari (desktop + mobile).
  • Devices: laptop, PC, phone.
  • Logout / login, revoke Drive access and re-grant.
  • Switch models (2.5 Pro → Flash → 3.0 and back).
  • Delete images / messages from history.
  • Hard refresh (Ctrl+F5), clear cache/cookies .
  • Scroll to top of history and try again.
  • Wait 15+ hours — no change.

This seems like a backend state corruption after processing images in long conversations — common recurring issue from 2025–2026 threads, but no permanent fix for affected chats.

Please investigate or provide a way to recover/repair these specific chat states. If needed, I can provide chat IDs / screenshots privately.

Thanks for any help or acknowledgment!

Hello, did you find any solutions? I’ve been struggling with this problem since yesterday afternoon and nothing is helping

changing the media resolution and scrolling back a bit in the chat seemed to fix the issue. give it a try.

UPDATE: Found a more complete fix — here’s the mechanics of why it works

After more investigation, I believe I’ve identified the root cause and a reliable fix for the “Internal Error” in chats with file attachments.

Root Cause: AI Studio uses virtual scrolling — it only renders content that’s currently visible in your browser viewport. When you’re at the bottom of a long chat, the file attachment near the top is essentially unloaded from active browser memory. When the backend tries to reindex the file to generate a response, the browser has nothing to hand it — causing the bottleneck that triggers the internal error.

The Fix:

  1. Ctrl+Home — jump to the top of the chat, forcing the file to load into active browser memory

  2. Change media resolution (high or default) — triggers a reindex while the file is actually loaded in the viewport

  3. Ctrl+End — scroll to the bottom to load the end session state

  4. Ctrl+Home — return to top to confirm the file is still loaded

  5. Hard refresh (Ctrl+Shift+R) — clears the corrupted session while preserving the freshly reindexed file state

  6. Retry generating — clean attempt with properly indexed file

This is why the media resolution trick worked before — if your chat wasn’t too long, simply scrolling up slightly would auto-trigger the file reload. But in very long chats, the file is too far from the viewport for that to happen automatically, which is why the trick became inconsistent over time.

Note: If your chat is SO long that even this fails, the nuclear option is deleting the attachment entirely — the chat will work again, but obviously without the file.

Tagging @Logan_Kilpatrick in hopes this helps the team identify the virtual scrolling / file reindexing pipeline issue on the backend.