Refactor beforeAgent and afterAgent hookEvents to follow desired output (#16495)

This commit is contained in:
Vedant Mahajan
2026-01-13 22:20:54 +05:30
committed by GitHub
parent 304caa4e43
commit a6dca02344
3 changed files with 28 additions and 69 deletions

View File

@@ -18,6 +18,7 @@ import type {
SessionStartSource,
SessionEndReason,
PreCompressTrigger,
DefaultHookOutput,
} from './types.js';
import type { AggregatedHookResult } from './hookAggregator.js';
/**
@@ -120,25 +121,27 @@ export class HookSystem {
async fireBeforeAgentEvent(
prompt: string,
): Promise<AggregatedHookResult | undefined> {
): Promise<DefaultHookOutput | undefined> {
if (!this.config.getEnableHooks()) {
return undefined;
}
return this.hookEventHandler.fireBeforeAgentEvent(prompt);
const result = await this.hookEventHandler.fireBeforeAgentEvent(prompt);
return result.finalOutput;
}
async fireAfterAgentEvent(
prompt: string,
response: string,
stopHookActive: boolean = false,
): Promise<AggregatedHookResult | undefined> {
): Promise<DefaultHookOutput | undefined> {
if (!this.config.getEnableHooks()) {
return undefined;
}
return this.hookEventHandler.fireAfterAgentEvent(
const result = await this.hookEventHandler.fireAfterAgentEvent(
prompt,
response,
stopHookActive,
);
return result.finalOutput;
}
}