Peristent "Invalid argument" *UPDATED*

I keep getting “Invalid argument” no matter what i try.
I’ve searched through the forum for any answers on this and tried several “solutions” like adding keys, rinse the chat etc. To no avail.

EDIT I went back to an earlier version and now it seems to be working again. Unless some of you support guys/gals have done something. Anyways, the issue seems to have been "solved" thus far.

Regards

Patrick

Unfortunately the issue came back. It worked for a few chat messages then i got “invalid argument” once again. And now going back to other versions doesn’t work anylonger.

EDIT Ok, so now i moved forward to a newer version, back to an old version and back to the new one again and it started to work again. Very strange behaviour…

A small update of what i suspect is the issue with “invalid argument”;
It’s about the context memory running out. If you upload files, screenshots and/or send alot for the agent to “contemplate” you get “invalid argument” when context memory runs out.

EDIT What i accidentally found out was that it’s not the actual size, it’s the files going past the upload filter that cause this. If you upload through the file explorer you will go around the chats upload filter and it will work without getting invalid arguments.

Solution:
How to solve the “invalid argument” issue after the fact it occurs; you will have to go to settings/versions and change to an older version before you got it. And hopefully you haven’t done too many changes between the working version and when you got the issue.

The reason this happens persistently—and why rolling back prompt versions temporarily “fixes” it—is chat history poisoning.

In Google AI Studio, every new message re-sends the entire preceding conversation history (all turns and attachments) to the backend. If an uploaded file, screenshot, or drag-and-dropped asset fails backend processing, expires, or has an unrecognised MIME type, that invalid part gets locked into the chat history array. Every subsequent prompt re-submits that broken attachment, triggering a continuous 400 INVALID_ARGUMENT.

Going back to an older version works only because it rewinds history to before that specific turn was added.

A faster fix without losing your prompt edits:

  1. Delete the offending turn: Instead of rolling back the entire prompt version, hover over the specific message turn where you attached the file/screenshot and delete just that turn.
  2. Avoid raw clipboard image pasting in long chats: Pasting directly into the prompt box can inject inline base64 blobs that trigger payload size errors or corrupt turn parsing. Save the image locally first and upload via the file button.
  3. Inspect via “Get Code”: Click Get Code (top right). If you see an empty inline_data block or an invalid file_data URI in the contents list, that is the exact turn failing schema validation.

Thank you! Excellent addition!