mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-06-14 05:17:18 -07:00
Feature: Implement V0 Episodic Context Manager
- Re-wrote the monolithic string-based context manipulation logic into an elegant, immutable Episodic IR pipeline. - Implemented four non-destructive degradation processors: `HistorySquashingProcessor`, `ToolMaskingProcessor`, `BlobDegradationProcessor`, and `SemanticCompressionProcessor`. - Added dynamic configuration knobs (`budget` and `strategies`) to precisely tune the retention algorithms. - Implemented a power-user `incrementalGc` flag for maximum context preservation beneath the ceiling. - Enforced strict typing across the new pipeline, replacing unsafe casts with robust mapping interfaces. - Added `powerUserProfile` to support features for those wanting a bit more quality at the cost of tokens.
This commit is contained in:
@@ -21,7 +21,7 @@ import {
|
||||
type MCPServerConfig,
|
||||
type GeminiCLIExtension,
|
||||
Storage,
|
||||
generalistProfile,
|
||||
GENERALIST_PROFILE,
|
||||
type ContextManagementConfig,
|
||||
} from '@google/gemini-cli-core';
|
||||
import { loadCliConfig, parseArguments, type CliArgs } from './config.js';
|
||||
@@ -2211,7 +2211,7 @@ describe('loadCliConfig context management', () => {
|
||||
});
|
||||
const config = await loadCliConfig(settings, 'test-session', argv);
|
||||
expect(config.getContextManagementConfig()).toStrictEqual(
|
||||
generalistProfile,
|
||||
GENERALIST_PROFILE,
|
||||
);
|
||||
expect(config.isContextManagementEnabled()).toBe(true);
|
||||
});
|
||||
@@ -2220,24 +2220,19 @@ describe('loadCliConfig context management', () => {
|
||||
process.argv = ['node', 'script.js'];
|
||||
const argv = await parseArguments(createTestMergedSettings());
|
||||
const contextManagementConfig: Partial<ContextManagementConfig> = {
|
||||
historyWindow: {
|
||||
budget: {
|
||||
incrementalGc: false,
|
||||
maxTokens: 100_000,
|
||||
retainedTokens: 50_000,
|
||||
protectedEpisodes: 1,
|
||||
protectSystemEpisode: true,
|
||||
},
|
||||
messageLimits: {
|
||||
normalMaxTokens: 1000,
|
||||
retainedMaxTokens: 10_000,
|
||||
normalizationHeadRatio: 0.25,
|
||||
},
|
||||
tools: {
|
||||
distillation: {
|
||||
maxOutputTokens: 10_000,
|
||||
summarizationThresholdTokens: 15_000,
|
||||
},
|
||||
outputMasking: {
|
||||
protectionThresholdTokens: 30_000,
|
||||
minPrunableThresholdTokens: 10_000,
|
||||
protectLatestTurn: false,
|
||||
strategies: {
|
||||
historySquashing: { maxTokensPerNode: 12000 },
|
||||
toolMasking: { stringLengthThresholdTokens: 10000 },
|
||||
semanticCompression: {
|
||||
nodeThresholdTokens: 5000,
|
||||
compressionModel: 'chat-compression-2.5-flash-lite',
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -46,7 +46,8 @@ import {
|
||||
type HookEventName,
|
||||
type OutputFormat,
|
||||
detectIdeFromEnv,
|
||||
generalistProfile,
|
||||
GENERALIST_PROFILE,
|
||||
POWER_USER_PROFILE,
|
||||
} from '@google/gemini-cli-core';
|
||||
import {
|
||||
type Settings,
|
||||
@@ -886,12 +887,15 @@ export async function loadCliConfig(
|
||||
|
||||
const useGeneralistProfile =
|
||||
settings.experimental?.generalistProfile ?? false;
|
||||
const usePowerUserProfile =
|
||||
settings.experimental?.powerUserProfile ?? false;
|
||||
const useContextManagement =
|
||||
settings.experimental?.contextManagement ?? false;
|
||||
const contextManagement = {
|
||||
...(useGeneralistProfile ? generalistProfile : {}),
|
||||
...(useGeneralistProfile ? GENERALIST_PROFILE : {}),
|
||||
...(usePowerUserProfile ? POWER_USER_PROFILE : {}),
|
||||
...(useContextManagement ? settings?.contextManagement : {}),
|
||||
enabled: useContextManagement || useGeneralistProfile,
|
||||
enabled: useContextManagement || useGeneralistProfile || usePowerUserProfile,
|
||||
};
|
||||
|
||||
return new Config({
|
||||
|
||||
@@ -2149,6 +2149,15 @@ const SETTINGS_SCHEMA = {
|
||||
'Replace the built-in save_memory tool with a memory manager subagent that supports adding, removing, de-duplicating, and organizing memories.',
|
||||
showInDialog: true,
|
||||
},
|
||||
powerUserProfile: {
|
||||
type: 'boolean',
|
||||
label: 'Use the power user profile for massive contexts.',
|
||||
category: 'Experimental',
|
||||
requiresRestart: true,
|
||||
default: false,
|
||||
description: 'Enables continuous minimal GC near the max tokens limit instead of a blocked backbuffer.',
|
||||
showInDialog: true,
|
||||
},
|
||||
generalistProfile: {
|
||||
type: 'boolean',
|
||||
label: 'Use the generalist profile to manage agent contexts.',
|
||||
|
||||
Reference in New Issue
Block a user