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

Silent data loss and conversation truncation in chat save/resume operations

Open shivas1432 opened this issue 1 year ago • 2 comments

What happened?

Chat conversations are being silently truncated during save operations without any error messages or warnings. Long conversations (100+ exchanges) consistently lose 50-70% of their content when saved and resumed, with no indication that data loss occurred.

Data loss pattern discovered:

  • Short conversations (1-30 exchanges): 100% success rate
  • Medium conversations (31-70 exchanges): 85% success rate, minor truncation
  • Long conversations (71-150 exchanges): 40% success rate, significant data loss
  • Very long conversations (150+ exchanges): 10% success rate, severe truncation

Critical failure characteristics:

  • /chat save always reports "Conversation saved successfully" even when truncating
  • No error messages or warnings during save process
  • Data loss only discovered when using /chat resume
  • Truncation appears to happen during save, not during resume
  • No recovery mechanism for corrupted conversations

What did you expect to happen?

Chat save operations should preserve the complete conversation history without any data loss. If technical limitations prevent saving large conversations, the system should:

  • Display clear error messages when saves fail
  • Warn users about potential truncation before saving
  • Provide options to compress or split large conversations
  • Implement data integrity verification
  • Offer recovery mechanisms for failed saves

Expected: /chat save should either save the complete conversation or fail with a clear error message.

Client information

Platform: Ubuntu 22.04 LTS and Windows

CLI Version: 0.1.18 Model: gemini-2.5-pro and gemini-2.5-flash (both affected) Checkpoint storage: ~/.config/google-generative-ai/checkpoints/

File system investigation:

ls -la ~/.config/google-generative-ai/checkpoints/
-rw-r--r-- short-session.json     15KB  # Complete
-rw-r--r-- long-session.json      52KB  # Should be ~200KB+



API Key (Google AI Studio) - issue also reproduced with OAuth authentication



might works this sol:
Data integrity validation for all save operations
Clear error messages when saves fail due to size limits
Automatic backup mechanisms for critical conversations
Recovery tools for corrupted checkpoint files
Conversation size warnings before potential truncation

shivas1432 avatar Aug 10 '25 15:08 shivas1432

Thanks for reporting this — data loss in saved conversations is definitely critical.
Until this gets a proper fix, here are a few workarounds you could try to reduce the risk:

  • Manually split long conversations into smaller chunks before running /chat save to avoid hitting hidden size limits.
  • Export conversation logs to a separate file (e.g., chat export > backup.json) as a backup before saving via the CLI.
  • Compress and archive sessions manually with tools like gzip if file size is the bottleneck.
  • Use version control (e.g., Git) on your checkpoints directory so you can roll back if truncation happens.
  • Verify saved file size right after saving — if it’s unexpectedly small, restore from your backup before resuming.

These aren’t perfect solutions, but they can help prevent total loss until the CLI adds proper:

  • Data integrity validation
  • File size warnings
  • Automatic backups and recovery tools

MustafaKemal0146 avatar Aug 10 '25 16:08 MustafaKemal0146

This is intentional. We automatically compress chat history when it grows beyond a certain number of tokens. The process is identical to running /compress. You can confirm this is the case by looking at the chat json to see for an entry with the text Got it. Thanks for the additional context! That's the text indicating that the chat was compressed at some point.

Please let us know if that's not the case or if we have evidence that the context is being compressed unnecessarily.

scidomino avatar Aug 18 '25 19:08 scidomino