From 65c1283338032ba79c0413eb9f1df662f1dea9c5 Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Fri, 15 May 2026 21:29:21 +0900 Subject: [PATCH] fix(todo-continuation): clean up idle event diagnostics --- .../todo-continuation-enforcer/idle-event.ts | 16 ++++++++-------- .../non-idle-events.ts | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/hooks/todo-continuation-enforcer/idle-event.ts b/src/hooks/todo-continuation-enforcer/idle-event.ts index 340e1ab26..4e4b63654 100644 --- a/src/hooks/todo-continuation-enforcer/idle-event.ts +++ b/src/hooks/todo-continuation-enforcer/idle-event.ts @@ -2,19 +2,19 @@ import type { PluginInput } from "@opencode-ai/plugin" import type { BackgroundManager } from "../../features/background-agent" import { getSessionAgent } from "../../features/claude-code-session-state" import { normalizeSDKResponse } from "../../shared" -import { log } from "../../shared/logger" import { getAgentConfigKey } from "../../shared/agent-display-names" +import { log } from "../../shared/logger" -import { ABORT_WINDOW_MS, CONTINUATION_COOLDOWN_MS, DEFAULT_SKIP_AGENTS, FAILURE_RESET_WINDOW_MS, HOOK_NAME, MAX_CONSECUTIVE_FAILURES } from "./constants" import { isLastAssistantMessageAborted } from "./abort-detection" +import { acknowledgeCompactionGuard, isCompactionGuardActive } from "./compaction-guard" +import { ABORT_WINDOW_MS, CONTINUATION_COOLDOWN_MS, DEFAULT_SKIP_AGENTS, FAILURE_RESET_WINDOW_MS, HOOK_NAME, MAX_CONSECUTIVE_FAILURES } from "./constants" +import { startCountdown } from "./countdown" import { hasUnansweredQuestion } from "./pending-question-detection" +import { resolveLatestMessageInfo } from "./resolve-message-info" +import type { SessionStateStore } from "./session-state" import { shouldStopForStagnation } from "./stagnation-detection" import { getIncompleteCount } from "./todo" -import type { MessageInfo, MessageWithInfo, ResolvedMessageInfo, Todo } from "./types" -import { resolveLatestMessageInfo } from "./resolve-message-info" -import { acknowledgeCompactionGuard, isCompactionGuardActive } from "./compaction-guard" -import type { SessionStateStore } from "./session-state" -import { startCountdown } from "./countdown" +import type { MessageWithInfo, ResolvedMessageInfo, Todo } from "./types" export async function handleSessionIdle(args: { ctx: PluginInput @@ -132,7 +132,7 @@ export async function handleSessionIdle(args: { } const effectiveCooldown = - CONTINUATION_COOLDOWN_MS * Math.pow(2, Math.min(state.consecutiveFailures, 5)) + CONTINUATION_COOLDOWN_MS * 2 ** Math.min(state.consecutiveFailures, 5) if (state.lastInjectedAt && Date.now() - state.lastInjectedAt < effectiveCooldown) { log(`[${HOOK_NAME}] Skipped: cooldown active`, { sessionID, effectiveCooldown, consecutiveFailures: state.consecutiveFailures }) return diff --git a/src/hooks/todo-continuation-enforcer/non-idle-events.ts b/src/hooks/todo-continuation-enforcer/non-idle-events.ts index 116369614..25a4de113 100644 --- a/src/hooks/todo-continuation-enforcer/non-idle-events.ts +++ b/src/hooks/todo-continuation-enforcer/non-idle-events.ts @@ -1,5 +1,5 @@ -import { log } from "../../shared/logger" import { resolveMessageEventSessionID, resolveSessionEventID } from "../../shared/event-session-id" +import { log } from "../../shared/logger" import { COUNTDOWN_GRACE_PERIOD_MS, HOOK_NAME } from "./constants" import type { SessionStateStore } from "./session-state"