fix(background-agent): queue notifications for idle parent sessions
When a background task completes and the parent session is waiting for user input, promptAsync() fails with an aborted error. Previously the notification was silently dropped — lost forever. Fix: queue the notification text in-memory on the BackgroundManager when promptAsync fails with an aborted/idle error. On the user's next message to that session, the queued notifications are injected into the chat context before the agent sees the message. - BackgroundManager: add pendingNotifications map + queuePendingNotification() and injectPendingNotificationsIntoChatMessage() methods - background-notification hook: add chat.message handler that calls injection - chat-message.ts: wire backgroundNotificationHook.chat.message into the message processing chain - Add tests covering queue-on-abort and next-message delivery
This commit is contained in:
@@ -97,6 +97,7 @@ export function createChatMessageHandler(args: {
|
||||
setSessionModel(input.sessionID, input.model)
|
||||
}
|
||||
await hooks.stopContinuationGuard?.["chat.message"]?.(input)
|
||||
await hooks.backgroundNotificationHook?.["chat.message"]?.(input, output)
|
||||
await hooks.runtimeFallback?.["chat.message"]?.(input, output)
|
||||
await hooks.keywordDetector?.["chat.message"]?.(input, output)
|
||||
await hooks.claudeCodeHooks?.["chat.message"]?.(input, output)
|
||||
|
||||
Reference in New Issue
Block a user