Skip to content

feat(core,cli): finalize context compression with batched routing#4

Open
thetomzohar wants to merge 12 commits intomainfrom
feature/clean-compression-flags
Open

feat(core,cli): finalize context compression with batched routing#4
thetomzohar wants to merge 12 commits intomainfrom
feature/clean-compression-flags

Conversation

@thetomzohar
Copy link
Copy Markdown
Owner

@thetomzohar thetomzohar commented Mar 18, 2026

Summary

Add support for context compression configurations via new CLI flags:
--compress (cloud context routing using flash compressor) and
--local-compress (local context routing using local ollama models). This
improves multi-turn tool performance by selectively compressing large file
payloads in history while retaining accuracy.

Details

  • Added Flags: --compress proxies file classification to Gemini cloud
    (compressor-2.5-flash-lite); --local-compress proxies it to local models
    over HTTP (getLocalContextCompressionModelUrl).
  • Core Integrations: Enhanced LocalContextCompressionService and updated
    GeminiClient to dynamically trigger compression before fetching chat turns
    based on the configured mode.
  • Batched Routing Optimization: Refactored ContextCompressionService to use a 4-pass batched sequence, reducing LLM overhead by grouping multiple file relevance queries into a single call.
  • Removed Debug Logs: Stripped all temporary telemetry instrumentation from
    experimental commits, ensuring clean integration with the trunk.

Related Issues

None.

How to Validate

  1. Run npm run build
  2. Start CLI with --compress: node packages/cli/bin/gemini.js --compress
  3. Load a large file into context via tool usage (e.g. read_file on
    package-lock.json).
  4. Perform subsequent turns and observe that history is successfully compressed
    transparently by checking the local compression_state.json file in your
    Gemini temp directory.

Pre-Merge Checklist

  • Updated relevant documentation and README (if needed)
  • Added/updated tests (if needed)
  • Noted breaking changes (if any)
  • Validated on required platforms/methods:
    • MacOS
      • npm run
      • npx
      • Docker
      • Podman
      • Seatbelt
    • Windows
      • npm run
      • npx
      • Docker
    • Linux
      • npm run
      • npx
      • Docker

@thetomzohar thetomzohar force-pushed the feature/clean-compression-flags branch 3 times, most recently from 1ef9b2f to b70725e Compare March 18, 2026 17:25
@thetomzohar thetomzohar force-pushed the feature/clean-compression-flags branch from b70725e to bad96cd Compare March 18, 2026 17:46
Tom Zohar added 8 commits March 18, 2026 20:16
1. Fix AbortSignal propagation in local/cloud compression to cancel requests properly.

2. Add proper tests and remove duplicated license header.
…xtCompressionService

This commit standardizes the service and config names to reflect that it handles both local and cloud modes.
… telemetry handling

This commit corrects a condition where compression breaks the functionCall/functionResponse adjacency invariant by gracefully ignoring edge-cases. It also cleans up temporary telemetry traces to prepare the code for branch PR submission.
- Restore chatCommand and logger compression checkpointing state logic
- Reposition setCurrentPrompt block above pre-route compression invocations
- Append pending mock logic hooks into unit test configurations
- Remove dangling settings load statement whitespace in CLI layer
@thetomzohar thetomzohar changed the title feat(core): add local and cloud context compression variants via flags feat(core,cli): finalize context compression with batched routing Mar 28, 2026
joshualitt added a commit to google-gemini/gemini-cli that referenced this pull request Apr 1, 2026
* Upstreams the ContextCompressionService from: thetomzohar#4
* Some minor tidying.
joshualitt added a commit to google-gemini/gemini-cli that referenced this pull request Apr 1, 2026
* Upstreams the ContextCompressionService from: thetomzohar#4
* Some minor tidying.
joshualitt added a commit to google-gemini/gemini-cli that referenced this pull request Apr 2, 2026
* 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 added a commit to google-gemini/gemini-cli that referenced this pull request Apr 2, 2026
* 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 added a commit to google-gemini/gemini-cli that referenced this pull request Apr 2, 2026
* 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 added a commit to google-gemini/gemini-cli that referenced this pull request Apr 2, 2026
* 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 added a commit to google-gemini/gemini-cli that referenced this pull request Apr 2, 2026
* 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 added a commit to google-gemini/gemini-cli that referenced this pull request Apr 2, 2026
* 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 added a commit to google-gemini/gemini-cli that referenced this pull request Apr 2, 2026
* 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 added a commit to google-gemini/gemini-cli that referenced this pull request Apr 2, 2026
* 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 added a commit to google-gemini/gemini-cli that referenced this pull request Apr 2, 2026
* 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 added a commit to google-gemini/gemini-cli that referenced this pull request Apr 2, 2026
* 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 added a commit to google-gemini/gemini-cli that referenced this pull request Apr 2, 2026
* Upstreams the ContextCompressionService from: thetomzohar#4
* Some minor tidying.
* Refactor: Rename ContextManager to MemoryContextManager
* Settings: Add experimental.generalistProfile to safely default context management hyperparameters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant