feat(context-window-recovery): gate JSON writes on OpenCode beta
This commit is contained in:
parent
b0944b7fd1
commit
e34fbd08a9
@ -4,6 +4,8 @@ import { join } from "node:path"
|
|||||||
import { getMessageIds } from "./message-storage-directory"
|
import { getMessageIds } from "./message-storage-directory"
|
||||||
import { PART_STORAGE_DIR, TRUNCATION_MESSAGE } from "./storage-paths"
|
import { PART_STORAGE_DIR, TRUNCATION_MESSAGE } from "./storage-paths"
|
||||||
import type { StoredToolPart, ToolResultInfo } from "./tool-part-types"
|
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[] {
|
export function findToolResultsBySize(sessionID: string): ToolResultInfo[] {
|
||||||
const messageIds = getMessageIds(sessionID)
|
const messageIds = getMessageIds(sessionID)
|
||||||
@ -48,6 +50,11 @@ export function truncateToolResult(partPath: string): {
|
|||||||
toolName?: string
|
toolName?: string
|
||||||
originalSize?: number
|
originalSize?: number
|
||||||
} {
|
} {
|
||||||
|
if (isSqliteBackend()) {
|
||||||
|
log.warn("[context-window-recovery] Disabled on SQLite backend: truncateToolResult")
|
||||||
|
return { success: false }
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const content = readFileSync(partPath, "utf-8")
|
const content = readFileSync(partPath, "utf-8")
|
||||||
const part = JSON.parse(content) as StoredToolPart
|
const part = JSON.parse(content) as StoredToolPart
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user