mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-21 02:24:09 -07:00
feat(hooks): Hook Session Lifecycle & Compression Integration (#14151)
This commit is contained in:
@@ -21,6 +21,8 @@ import {
|
||||
DEFAULT_GEMINI_MODEL,
|
||||
PREVIEW_GEMINI_MODEL,
|
||||
} from '../config/models.js';
|
||||
import { firePreCompressHook } from '../core/sessionHookTriggers.js';
|
||||
import { PreCompressTrigger } from '../hooks/types.js';
|
||||
|
||||
/**
|
||||
* Default threshold for compression token count as a fraction of the model's
|
||||
@@ -123,6 +125,17 @@ export class ChatCompressionService {
|
||||
};
|
||||
}
|
||||
|
||||
// Fire PreCompress hook before compression (only if hooks are enabled)
|
||||
// This fires for both manual and auto compression attempts
|
||||
const hooksEnabled = config.getEnableHooks();
|
||||
const messageBus = config.getMessageBus();
|
||||
if (hooksEnabled && messageBus) {
|
||||
const trigger = force
|
||||
? PreCompressTrigger.Manual
|
||||
: PreCompressTrigger.Auto;
|
||||
await firePreCompressHook(messageBus, trigger);
|
||||
}
|
||||
|
||||
const originalTokenCount = chat.getLastPromptTokenCount();
|
||||
|
||||
// Don't compress if not forced and we are under the limit.
|
||||
|
||||
Reference in New Issue
Block a user