Skip to content

feat(core): Land ContextCompressionService#24483

Merged
joshualitt merged 2 commits intomainfrom
jl/merge-context-compression
Apr 2, 2026
Merged

feat(core): Land ContextCompressionService#24483
joshualitt merged 2 commits intomainfrom
jl/merge-context-compression

Conversation

@joshualitt
Copy link
Copy Markdown
Contributor

@joshualitt joshualitt commented Apr 1, 2026

Part of the work for #24482, context compression will be integrated into the context management pipeline in a follow-up.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 1, 2026

🧠 Model Steering Guidance

This PR modifies files that affect the model's behavior (prompts, tools, or instructions).

  • ⚠️ Consider adding Evals: No behavioral evaluations (evals/*.eval.ts) were added or updated in this PR. Consider adding a test case to verify the new behavior and prevent regressions.
  • 🚀 Maintainer Reminder: Please ensure that these changes do not regress results on benchmark evals before merging.

This is an automated guidance message triggered by steering logic signatures.

@gemini-cli gemini-cli Bot added the area/agent Issues related to Core Agent, Tools, Memory, Sub-Agents, Hooks, Agent Quality label Apr 1, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 1, 2026

Size Change: +1.04 kB (0%)

Total Size: 34.6 MB

Filename Size Change
./bundle/chunk-RNKDRUVQ.js 0 B -3.82 MB (removed) 🏆
./bundle/chunk-UTLKMMKJ.js 0 B -14.8 MB (removed) 🏆
./bundle/core-DCHXDZ2G.js 0 B -45 kB (removed) 🏆
./bundle/devtoolsService-RXVIDKUS.js 0 B -28.4 kB (removed) 🏆
./bundle/interactiveCli-QUQNK7WT.js 0 B -1.67 MB (removed) 🏆
./bundle/oauth2-provider-QJVXSJVO.js 0 B -9.16 kB (removed) 🏆
./bundle/chunk-5LANSVKL.js 3.82 MB +3.82 MB (new file) 🆕
./bundle/chunk-IHHA6CQQ.js 14.8 MB +14.8 MB (new file) 🆕
./bundle/core-XYH3YIMU.js 45.1 kB +45.1 kB (new file) 🆕
./bundle/devtoolsService-JTWP4H33.js 28.4 kB +28.4 kB (new file) 🆕
./bundle/interactiveCli-LHBAWF7P.js 1.67 MB +1.67 MB (new file) 🆕
./bundle/oauth2-provider-KVN6MLHW.js 9.16 kB +9.16 kB (new file) 🆕
ℹ️ View Unchanged
Filename Size Change
./bundle/bundled/third_party/index.js 8 MB 0 B
./bundle/chunk-34MYV7JD.js 2.45 kB 0 B
./bundle/chunk-5AUYMPVF.js 858 B 0 B
./bundle/chunk-664ZODQF.js 124 kB 0 B
./bundle/chunk-DAHVX5MI.js 206 kB 0 B
./bundle/chunk-IUUIT4SU.js 56.5 kB 0 B
./bundle/chunk-RJTRUG2J.js 39.8 kB 0 B
./bundle/chunk-U4FACSVX.js 1.13 kB 0 B
./bundle/chunk-VIMQWW3W.js 1.96 MB 0 B
./bundle/devtools-36NN55EP.js 696 kB 0 B
./bundle/dist-T73EYRDX.js 356 B 0 B
./bundle/events-CLX3JQHP.js 418 B 0 B
./bundle/gemini.js 533 kB +293 B (+0.06%)
./bundle/getMachineId-bsd-TXG52NKR.js 1.55 kB 0 B
./bundle/getMachineId-darwin-7OE4DDZ6.js 1.55 kB 0 B
./bundle/getMachineId-linux-SHIFKOOX.js 1.34 kB 0 B
./bundle/getMachineId-unsupported-5U5DOEYY.js 1.06 kB 0 B
./bundle/getMachineId-win-6KLLGOI4.js 1.72 kB 0 B
./bundle/memoryDiscovery-CCA7SXYN.js 980 B 0 B
./bundle/multipart-parser-KPBZEGQU.js 11.7 kB 0 B
./bundle/node_modules/@google/gemini-cli-devtools/dist/client/main.js 222 kB 0 B
./bundle/node_modules/@google/gemini-cli-devtools/dist/src/_client-assets.js 229 kB 0 B
./bundle/node_modules/@google/gemini-cli-devtools/dist/src/index.js 13.4 kB 0 B
./bundle/node_modules/@google/gemini-cli-devtools/dist/src/types.js 132 B 0 B
./bundle/sandbox-macos-permissive-open.sb 890 B 0 B
./bundle/sandbox-macos-permissive-proxied.sb 1.31 kB 0 B
./bundle/sandbox-macos-restrictive-open.sb 3.36 kB 0 B
./bundle/sandbox-macos-restrictive-proxied.sb 3.56 kB 0 B
./bundle/sandbox-macos-strict-open.sb 4.82 kB 0 B
./bundle/sandbox-macos-strict-proxied.sb 5.02 kB 0 B
./bundle/src-QVCVGIUX.js 47 kB 0 B
./bundle/tree-sitter-7U6MW5PS.js 274 kB 0 B
./bundle/tree-sitter-bash-34ZGLXVX.js 1.84 MB 0 B

compressed-size-action

@joshualitt joshualitt force-pushed the jl/merge-context-compression branch 6 times, most recently from 788d705 to 12dfb33 Compare April 2, 2026 01:02
@joshualitt joshualitt force-pushed the jl/merge-context-compression branch 2 times, most recently from 2e32ca0 to 9cfdce6 Compare April 2, 2026 02:26
@joshualitt joshualitt marked this pull request as ready for review April 2, 2026 02:33
@joshualitt joshualitt requested review from a team as code owners April 2, 2026 02:33
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request integrates a new context compression service to improve the efficiency of the context management pipeline. It includes structural refactoring of existing context management classes, the addition of a new experimental generalist profile for better default settings, and a cleanup of configuration APIs to support more granular context control.

Highlights

  • ContextCompressionService: Introduced the ContextCompressionService to optimize context management by routing file content through compression levels (FULL, PARTIAL, SUMMARY, EXCLUDED).
  • Refactoring: Renamed ContextManager to MemoryContextManager to better reflect its role in the context management pipeline.
  • Configuration: Added experimental.generalistProfile setting to provide default hyperparameters for context management, optimized for general coding tasks.
  • API Updates: Renamed isAutoDistillationEnabled to isContextManagementEnabled across the codebase to align with broader context management features.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new experimental generalistProfile and a ContextCompressionService to manage agent context more efficiently. The generalistProfile provides a set of default configurations for context management, while the ContextCompressionService uses an LLM to decide whether to provide full file content, snippets, or summaries in the conversation history. Several critical issues were identified in the new compression logic, including a bug in the enabled flag logic that prevents disabling the feature, incorrect iteration over file paths in the protection logic, and multiple instances of missing input sanitization which could lead to prompt injection.

Comment thread packages/cli/src/config/config.ts Outdated
Comment thread packages/core/src/context/contextCompressionService.ts Outdated
Comment thread packages/core/src/context/contextCompressionService.ts
Comment thread packages/core/src/context/contextCompressionService.ts
@joshualitt joshualitt force-pushed the jl/merge-context-compression branch 3 times, most recently from 8e16db8 to dcbefb4 Compare April 2, 2026 04:31
Comment thread packages/core/src/context/contextCompressionService.ts Outdated
* Upstreams the ContextCompressionService from: thetomzohar#4
* Some minor tidying.
* Refactor: Rename ContextManager to MemoryContextManager
* Settings: Add experimental.generalistProfile to safely default context management hyperparameters
@joshualitt joshualitt force-pushed the jl/merge-context-compression branch from c384557 to d3c4e71 Compare April 2, 2026 15:43
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 2, 2026

55 tests passed successfully on gemini-3-flash-preview.

🧠 Model Steering Guidance

This PR modifies files that affect the model's behavior (prompts, tools, or instructions).

  • ⚠️ Consider adding Evals: No behavioral evaluations (evals/*.eval.ts) were added or updated in this PR. Consider adding a test case to verify the new behavior and prevent regressions.
  • 🚀 Maintainer Reminder: Please ensure that these changes do not regress results on benchmark evals before merging.

This is an automated guidance message triggered by steering logic signatures.

@joshualitt joshualitt added this pull request to the merge queue Apr 2, 2026
Merged via the queue into main with commit e0044f2 Apr 2, 2026
27 of 28 checks passed
@joshualitt joshualitt deleted the jl/merge-context-compression branch April 2, 2026 16:36
kalenkevich pushed a commit to kalenkevich/gemini-cli that referenced this pull request Apr 3, 2026
afanty2021 pushed a commit to afanty2021/gemini-cli that referenced this pull request Apr 4, 2026
warrenzhu25 pushed a commit to warrenzhu25/gemini-cli that referenced this pull request Apr 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/agent Issues related to Core Agent, Tools, Memory, Sub-Agents, Hooks, Agent Quality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants