gemini-cli icon indicating copy to clipboard operation
gemini-cli copied to clipboard

[API Error: * CountTokensRequest.contents[2].parts[0].data: required oneof field 'data' must have one initialized field (Status: INVALID_ARGUMENT)]

Open imtiazsohel-git opened this issue 1 year ago • 3 comments

What happened?

When i try to compress chat history it shows this error:

Failed to compress chat history: {"error":{"code":400,"message":"* CountTokensRequest.contents[2].parts[0].data: required one of field 'data' must have one initialized field\n","status":"INVALID_ARGUMENT"}}

also

After i resume chat history, gemini cli resumes history but after that any commands throws this error:

[API Error: * CountTokensRequest.contents[2].parts[0].data: required oneof field 'data' must have one initialized field (Status: INVALID_ARGUMENT)]

This happened after i have updated to 0.1.16 from 0.1.15. i have also noticed that in my google cloud api console, before the update gemini 2.5 flash was used for compressing and after the update, gemini 2.5 flash lite was used. i am not sure about this , but this might be a issue.

What did you expect to happen?

It compresses the history like before and I can chat normally.

Client information

CLI Version 0.1.16
Git Commit 820169ba (local modifications)
Model gemini-2.5-pro
Sandbox no sandbox
OS win32
Auth Method gemini-api-key

Login information

Logging in with Gemini API key

Anything else we need to know?

No response

imtiazsohel-git avatar Aug 04 '25 11:08 imtiazsohel-git

I faced this as well today

Failed to compress chat history: {"error":{"code":400,"message":"* CountTokensRequest.contents[2].parts[0].data: required oneof field 'data' must have one initialized field\n","status":"INVALID_ARGUMENT"}}

yashasvigirdhar avatar Aug 04 '25 14:08 yashasvigirdhar

For visibility, I'm mentioning my analysis from issue #5592 here.

can-non avatar Aug 18 '25 16:08 can-non

This appears to have been addressedin #5592 Please don't hesitate to let us know if you are still seeing this issue.

srithreepo avatar Oct 02 '25 01:10 srithreepo