From e6883a45e28d8dea2d7f7b72fe1e99a6b9ebf315 Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Sat, 21 Feb 2026 02:23:22 +0900 Subject: [PATCH] fix(session-recovery): wire unavailable_tool recovery in hook --- src/hooks/session-recovery/hook.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/hooks/session-recovery/hook.ts b/src/hooks/session-recovery/hook.ts index 8dedd3a0..7335c2db 100644 --- a/src/hooks/session-recovery/hook.ts +++ b/src/hooks/session-recovery/hook.ts @@ -5,6 +5,7 @@ import { detectErrorType } from "./detect-error-type" import type { RecoveryErrorType } from "./detect-error-type" import type { MessageData } from "./types" import { recoverToolResultMissing } from "./recover-tool-result-missing" +import { recoverUnavailableTool } from "./recover-unavailable-tool" import { recoverThinkingBlockOrder } from "./recover-thinking-block-order" import { recoverThinkingDisabledViolation } from "./recover-thinking-disabled-violation" import { extractResumeConfig, findLastUserMessage, resumeSession } from "./resume" @@ -79,12 +80,14 @@ export function createSessionRecoveryHook(ctx: PluginInput, options?: SessionRec const toastTitles: Record = { tool_result_missing: "Tool Crash Recovery", + unavailable_tool: "Tool Recovery", thinking_block_order: "Thinking Block Recovery", thinking_disabled_violation: "Thinking Strip Recovery", "assistant_prefill_unsupported": "Prefill Unsupported", } const toastMessages: Record = { tool_result_missing: "Injecting cancelled tool results...", + unavailable_tool: "Recovering from unavailable tool call...", thinking_block_order: "Fixing message structure...", thinking_disabled_violation: "Stripping thinking blocks...", "assistant_prefill_unsupported": "Prefill not supported; continuing without recovery.", @@ -105,6 +108,13 @@ export function createSessionRecoveryHook(ctx: PluginInput, options?: SessionRec if (errorType === "tool_result_missing") { success = await recoverToolResultMissing(ctx.client, sessionID, failedMsg) + } else if (errorType === "unavailable_tool") { + success = await recoverUnavailableTool(ctx.client, sessionID, failedMsg) + if (success && experimental?.auto_resume) { + const lastUser = findLastUserMessage(msgs ?? []) + const resumeConfig = extractResumeConfig(lastUser, sessionID) + await resumeSession(ctx.client, resumeConfig) + } } else if (errorType === "thinking_block_order") { success = await recoverThinkingBlockOrder(ctx.client, sessionID, failedMsg, ctx.directory, info.error) if (success && experimental?.auto_resume) {