feat: improve SessionStart hooks and feedback injection (#803)

Co-authored-by: Letta <noreply@letta.com>
This commit is contained in:
jnjpng
2026-02-03 15:57:58 -08:00
committed by GitHub
parent 8bc50b58ee
commit e2a0545a01
3 changed files with 106 additions and 7 deletions

View File

@@ -379,6 +379,8 @@ export async function runSetupHooks(
/**
* Run SessionStart hooks when a session begins
* Unlike other hooks, SessionStart collects stdout (not stderr) on exit 2
* to inject context into the first user message
*/
export async function runSessionStartHooks(
isNewSession: boolean,
@@ -405,7 +407,23 @@ export async function runSessionStartHooks(
conversation_id: conversationId,
};
return executeHooks(hooks, input, workingDirectory);
// Run hooks sequentially (SessionStart shouldn't block, but we collect feedback)
const result = await executeHooks(hooks, input, workingDirectory);
// For SessionStart, collect stdout from all hooks regardless of exit code
const feedback: string[] = [];
for (const hookResult of result.results) {
if (hookResult.stdout?.trim()) {
feedback.push(hookResult.stdout.trim());
}
}
return {
blocked: false, // SessionStart never blocks
errored: result.errored,
feedback,
results: result.results,
};
}
/**