Skip to content

Commit b1589be

Browse files
committed
add disable OPENCODE_DISABLE_AUTOCOMPACT
1 parent eb24d2f commit b1589be

2 files changed

Lines changed: 3 additions & 0 deletions

File tree

packages/opencode/src/flag/flag.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export namespace Flag {
88
export const OPENCODE_DISABLE_DEFAULT_PLUGINS = truthy("OPENCODE_DISABLE_DEFAULT_PLUGINS")
99
export const OPENCODE_DISABLE_LSP_DOWNLOAD = truthy("OPENCODE_DISABLE_LSP_DOWNLOAD")
1010
export const OPENCODE_ENABLE_EXPERIMENTAL_MODELS = truthy("OPENCODE_ENABLE_EXPERIMENTAL_MODELS")
11+
export const OPENCODE_DISABLE_AUTOCOMPACT = truthy("OPENCODE_DISABLE_AUTOCOMPACT")
1112

1213
function truthy(key: string) {
1314
const value = process.env[key]?.toLowerCase()

packages/opencode/src/session/compaction.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { Bus } from "../bus"
1010
import z from "zod"
1111
import type { ModelsDev } from "../provider/models"
1212
import { SessionPrompt } from "./prompt"
13+
import { Flag } from "../flag/flag"
1314

1415
export namespace SessionCompaction {
1516
export const Event = {
@@ -22,6 +23,7 @@ export namespace SessionCompaction {
2223
}
2324

2425
export function isOverflow(input: { tokens: MessageV2.Assistant["tokens"]; model: ModelsDev.Model }) {
26+
if (Flag.OPENCODE_DISABLE_AUTOCOMPACT) return false
2527
const count = input.tokens.input + input.tokens.cache.read + input.tokens.output
2628
const output = Math.min(input.model.limit.output, SessionPrompt.OUTPUT_TOKEN_MAX) || SessionPrompt.OUTPUT_TOKEN_MAX
2729
const usable = input.model.limit.context - output

0 commit comments

Comments
 (0)