fix: add explicit isSqliteBackend guards to pruning modules
This commit is contained in:
@@ -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<string>
|
||||
): number {
|
||||
if (isSqliteBackend()) {
|
||||
log("[pruning-deduplication] Skipping deduplication on SQLite backend")
|
||||
return 0
|
||||
}
|
||||
|
||||
if (!config.enabled) return 0
|
||||
|
||||
const messages = readMessages(sessionID)
|
||||
|
||||
@@ -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<string>,
|
||||
): { 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)
|
||||
|
||||
Reference in New Issue
Block a user