- Notifications
You must be signed in to change notification settings - Fork 0
Description
Problem
Session cleanup is handled inconsistently across hooks. Most hooks (autoCompact, sessionRecovery, tokenAwareTruncation, contextWindowMonitor, fileOpsTracker, fetchTracker) handle their own cleanup inside their event handler. But others expose a separate cleanupSession() method that src/index.ts calls manually:
// src/index.ts — index.ts shouldn't own this constraintReviewerHook.cleanupSession(sessionId); fetchTrackerHook.cleanupSession(sessionId);This creates a maintenance risk: any hook added in the future that holds per-session state must also be wired into this block in index.ts, and it's easy to miss.
Fix
Each hook that holds per-session state should clean itself up inside its own event handler, keyed on session.deleted. The index.ts event handler then only fans out to all hooks uniformly via await hook.event({ event }).
The constraintReviewerHook is the main outlier — its cleanupSession can be moved inside its event handler to match the established pattern.