@@ -7,13 +7,13 @@ import { Provider } from "../provider/provider"
77import { MessageV2 } from "./message-v2"
88import z from "zod"
99import { SessionPrompt } from "./prompt"
10- import { Flag } from "../flag/flag"
1110import { Token } from "../util/token"
1211import { Log } from "../util/log"
1312import { SessionProcessor } from "./processor"
1413import { fn } from "@/util/fn"
1514import { Agent } from "@/agent/agent"
1615import { Plugin } from "@/plugin"
16+ import { Config } from "@/config/config"
1717
1818export namespace SessionCompaction {
1919 const log = Log . create ( { service : "session.compaction" } )
@@ -27,8 +27,9 @@ export namespace SessionCompaction {
2727 ) ,
2828 }
2929
30- export function isOverflow ( input : { tokens : MessageV2 . Assistant [ "tokens" ] ; model : Provider . Model } ) {
31- if ( Flag . OPENCODE_DISABLE_AUTOCOMPACT ) return false
30+ export async function isOverflow ( input : { tokens : MessageV2 . Assistant [ "tokens" ] ; model : Provider . Model } ) {
31+ const config = await Config . get ( )
32+ if ( ( config . compaction ?. auto ?? true ) === false ) return false
3233 const context = input . model . limit . context
3334 if ( context === 0 ) return false
3435 const count = input . tokens . input + input . tokens . cache . read + input . tokens . output
@@ -46,7 +47,8 @@ export namespace SessionCompaction {
4647 // calls. then erases output of previous tool calls. idea is to throw away old
4748 // tool calls that are no longer relevant.
4849 export async function prune ( input : { sessionID : string } ) {
49- if ( Flag . OPENCODE_DISABLE_PRUNE ) return
50+ const config = await Config . get ( )
51+ if ( ( config . compaction ?. prune ?? true ) === false ) return
5052 log . info ( "pruning" )
5153 const msgs = await Session . messages ( { sessionID : input . sessionID } )
5254 let total = 0
0 commit comments