gemini-cli - 💡(How to fix) Fix [Bug] Exponential token leak and ID duplication in StateSnapshotAsyncProcessor [1 pull requests]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Fix Action

Fixed

Code Example

> /about
OS: win32 v24.15.0
CLI Version: 0.41.2
RAW_BUFFERClick to expand / collapse

What happened?

There is an exponential token scaling leak in the background StateSnapshotAsyncProcessor. When the episodic context graph exceeds the retainedTokens boundary, nodes_aged_out triggers the async processor. While it correctly loads the latest proposed accumulate snapshot draft from the inbox, it fails to filter the previously summarized nodes from targets.

This means nodesToSummarize retains the entire history of aged-out nodes. As a result, the summarizer model is repeatedly sent the entire history of aged-out nodes as raw transcript text on every background run (sending 5k tokens, then 10k, then 15k... instead of just the newly aged-out 5k tokens). This leads to millions of input tokens being consumed in long sessions (e.g., hitting 10M+ tokens).

Additionally, the newConsumedIds array blindly appends all targets.map(t => t.id) to previousConsumedIds on every run, leading to quadratic duplication of IDs in the proposed snapshot JSON payload.

What did you expect to happen?

The StateSnapshotAsyncProcessor should filter nodesToSummarize against the previousConsumedIds Set (from the loaded draft or baseline) so that the LLM only receives the newly aged-out nodes as raw transcript. Additionally, newConsumedIds should be deduplicated using a Set.

Client information

<details> <summary>Client Information</summary>
> /about
OS: win32 v24.15.0
CLI Version: 0.41.2
</details>

Login information

oauth-personal

Anything else we need to know?

I have a local fix ready and will be submitting a PR shortly.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

gemini-cli - 💡(How to fix) Fix [Bug] Exponential token leak and ID duplication in StateSnapshotAsyncProcessor [1 pull requests]