From e34fbd08a907dec070b5a57c38735d3e167646ae Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Sat, 14 Feb 2026 18:18:13 +0900 Subject: [PATCH] feat(context-window-recovery): gate JSON writes on OpenCode beta --- .../tool-result-storage.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/hooks/anthropic-context-window-limit-recovery/tool-result-storage.ts b/src/hooks/anthropic-context-window-limit-recovery/tool-result-storage.ts index 70d9ffa5d..7b62884cb 100644 --- a/src/hooks/anthropic-context-window-limit-recovery/tool-result-storage.ts +++ b/src/hooks/anthropic-context-window-limit-recovery/tool-result-storage.ts @@ -4,6 +4,8 @@ import { join } from "node:path" import { getMessageIds } from "./message-storage-directory" import { PART_STORAGE_DIR, TRUNCATION_MESSAGE } from "./storage-paths" import type { StoredToolPart, ToolResultInfo } from "./tool-part-types" +import { isSqliteBackend } from "../../shared/opencode-storage-detection" +import { log } from "../../shared/logger" export function findToolResultsBySize(sessionID: string): ToolResultInfo[] { const messageIds = getMessageIds(sessionID) @@ -48,6 +50,11 @@ export function truncateToolResult(partPath: string): { toolName?: string originalSize?: number } { + if (isSqliteBackend()) { + log.warn("[context-window-recovery] Disabled on SQLite backend: truncateToolResult") + return { success: false } + } + try { const content = readFileSync(partPath, "utf-8") const part = JSON.parse(content) as StoredToolPart