feat(core): implement session learnings summary hook

This commit is contained in:
Aishanee Shah
2026-02-11 16:32:15 +00:00
parent 84ce53aafa
commit f72359efef
6 changed files with 298 additions and 1 deletions

View File

@@ -33,6 +33,7 @@ import type {
ToolListUnion,
} from '@google/genai';
import type { ToolCallConfirmationDetails } from '../tools/tools.js';
import { SessionLearningsService } from '../services/sessionLearningsService.js';
/**
* Main hook system that coordinates all hook-related functionality
@@ -151,6 +152,7 @@ export class HookSystem {
private readonly hookAggregator: HookAggregator;
private readonly hookPlanner: HookPlanner;
private readonly hookEventHandler: HookEventHandler;
private readonly sessionLearningsService: SessionLearningsService;
constructor(config: Config) {
// Initialize components
@@ -164,6 +166,7 @@ export class HookSystem {
this.hookRunner,
this.hookAggregator,
);
this.sessionLearningsService = new SessionLearningsService(config);
}
/**
@@ -215,7 +218,14 @@ export class HookSystem {
async fireSessionEndEvent(
reason: SessionEndReason,
): Promise<AggregatedHookResult | undefined> {
return this.hookEventHandler.fireSessionEndEvent(reason);
const result = await this.hookEventHandler.fireSessionEndEvent(reason);
// Built-in system hook for session learnings
if (reason === 'exit' || reason === 'logout') {
await this.sessionLearningsService.generateAndSaveLearnings();
}
return result;
}
async firePreCompressEvent(