Deep dive
How Gemini CLI compresses chat history
When the prompt reaches half of the model's token limit, the newest 30% of the conversation is kept and the rest becomes a structured snapshot written by a model.
It then asks the model to critique its own summary. If the new history has more tokens than the old one, it is thrown away, and automatic attempts stop calling the summariser until a new chat starts.
Read the report → Working code →Deep dive
How Gemini CLI remembers, without a vector database
Memory is markdown files, each read in full. Three tiers decide where a file enters the prompt: the system instruction, the first user message, or a tool's result when that folder is first touched.
The model saves a memory by editing a file with its ordinary tools. No semantic database was found.
Read the report → Working code →