mirror of
https://github.com/sst/opencode.git
synced 2025-12-23 10:11:41 +00:00
add disable OPENCODE_DISABLE_AUTOCOMPACT
This commit is contained in:
parent
eb24d2f847
commit
b1589be4ba
2 changed files with 3 additions and 0 deletions
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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 false
|
||||
const count = input.tokens.input + input.tokens.cache.read + input.tokens.output
|
||||
const output = Math.min(input.model.limit.output, SessionPrompt.OUTPUT_TOKEN_MAX) || SessionPrompt.OUTPUT_TOKEN_MAX
|
||||
const usable = input.model.limit.context - output
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue