fix: ignore invalid claude hook starts

This commit is contained in:
William Valentin
2026-04-29 09:41:07 -07:00
parent 6799cc3681
commit fd17628e94
3 changed files with 206 additions and 165 deletions
+12 -1
View File
@@ -124,7 +124,18 @@ function emitError(sessionKey: string | undefined, runId: string | undefined, sp
}
async function handleSessionStart(input: Dict) {
const sessionKey = getSessionKey(input) || randomUUID();
const sessionKey = getSessionKey(input);
if (!sessionKey) {
console.error('[agentmon] ignoring claude-code session.start without session_id');
return;
}
const hookEventName = pickString(input.hook_event_name);
if (hookEventName && hookEventName !== 'SessionStart') {
console.error(`[agentmon] ignoring claude-code session.start with hook_event_name=${hookEventName}`);
return;
}
const runId = randomUUID();
activeRuns.set(sessionKey, runId);
saveState(sessionKey, { runId, spans: {} });