From d414f6daba5b656ae66633821137dea91d3b0619 Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Sun, 15 Feb 2026 14:50:32 +0900 Subject: [PATCH] fix: add explicit isSqliteBackend guards to pruning modules --- .../pruning-deduplication.ts | 7 +++++++ .../pruning-tool-output-truncation.ts | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/src/hooks/anthropic-context-window-limit-recovery/pruning-deduplication.ts b/src/hooks/anthropic-context-window-limit-recovery/pruning-deduplication.ts index 1598052c3..45e69bdae 100644 --- a/src/hooks/anthropic-context-window-limit-recovery/pruning-deduplication.ts +++ b/src/hooks/anthropic-context-window-limit-recovery/pruning-deduplication.ts @@ -4,6 +4,7 @@ import type { PruningState, ToolCallSignature } from "./pruning-types" import { estimateTokens } from "./pruning-types" import { log } from "../../shared/logger" import { getMessageDir } from "../../shared/opencode-message-dir" +import { isSqliteBackend } from "../../shared/opencode-storage-detection" export interface DeduplicationConfig { enabled: boolean @@ -44,6 +45,7 @@ function sortObject(obj: unknown): unknown { } function readMessages(sessionID: string): MessagePart[] { + if (isSqliteBackend()) return [] const messageDir = getMessageDir(sessionID) if (!messageDir) return [] @@ -71,6 +73,11 @@ export function executeDeduplication( config: DeduplicationConfig, protectedTools: Set ): number { + if (isSqliteBackend()) { + log("[pruning-deduplication] Skipping deduplication on SQLite backend") + return 0 + } + if (!config.enabled) return 0 const messages = readMessages(sessionID) diff --git a/src/hooks/anthropic-context-window-limit-recovery/pruning-tool-output-truncation.ts b/src/hooks/anthropic-context-window-limit-recovery/pruning-tool-output-truncation.ts index e92946335..b1fe9b333 100644 --- a/src/hooks/anthropic-context-window-limit-recovery/pruning-tool-output-truncation.ts +++ b/src/hooks/anthropic-context-window-limit-recovery/pruning-tool-output-truncation.ts @@ -4,6 +4,7 @@ import { getOpenCodeStorageDir } from "../../shared/data-path" import { truncateToolResult } from "./storage" import { log } from "../../shared/logger" import { getMessageDir } from "../../shared/opencode-message-dir" +import { isSqliteBackend } from "../../shared/opencode-storage-detection" interface StoredToolPart { type?: string @@ -39,6 +40,11 @@ export function truncateToolOutputsByCallId( sessionID: string, callIds: Set, ): { truncatedCount: number } { + if (isSqliteBackend()) { + log("[auto-compact] Skipping pruning tool outputs on SQLite backend") + return { truncatedCount: 0 } + } + if (callIds.size === 0) return { truncatedCount: 0 } const messageIds = getMessageIds(sessionID)