The open source coding agent.
TypeScript
add disable OPENCODE_DISABLE_AUTOCOMPACT
Dax Raadb1589be4ba03
diff --git a/packages/opencode/src/flag/flag.ts b/packages/opencode/src/flag/flag.tsindex 4af827d8b3f..418f32283f4 100644--- a/packages/opencode/src/flag/flag.ts+++ b/packages/opencode/src/flag/flag.ts@@ -8,6 +8,7 @@ export namespace Flag {export const OPENCODE_DISABLE_DEFAULT_PLUGINS = truthy("OPENCODE_DISABLE_DEFAULT_PLUGINS")export const OPENCODE_DISABLE_LSP_DOWNLOAD = truthy("OPENCODE_DISABLE_LSP_DOWNLOAD")export const OPENCODE_ENABLE_EXPERIMENTAL_MODELS = truthy("OPENCODE_ENABLE_EXPERIMENTAL_MODELS")+ export const OPENCODE_DISABLE_AUTOCOMPACT = truthy("OPENCODE_DISABLE_AUTOCOMPACT")function truthy(key: string) {const value = process.env[key]?.toLowerCase()diff --git a/packages/opencode/src/session/compaction.ts b/packages/opencode/src/session/compaction.tsindex 6039ed26320..e5b42469daa 100644--- a/packages/opencode/src/session/compaction.ts+++ b/packages/opencode/src/session/compaction.ts@@ -10,6 +10,7 @@ import { Bus } from "../bus"import z from "zod"import type { ModelsDev } from "../provider/models"import { SessionPrompt } from "./prompt"+import { Flag } from "../flag/flag"export namespace SessionCompaction {export const Event = {@@ -22,6 +23,7 @@ export namespace SessionCompaction {}export function isOverflow(input: { tokens: MessageV2.Assistant["tokens"]; model: ModelsDev.Model }) {+ if (Flag.OPENCODE_DISABLE_AUTOCOMPACT) return falseconst count = input.tokens.input + input.tokens.cache.read + input.tokens.outputconst output = Math.min(input.model.limit.output, SessionPrompt.OUTPUT_TOKEN_MAX) || SessionPrompt.OUTPUT_TOKEN_MAXconst usable = input.model.limit.context - output