@@ -694,17 +694,17 @@ If you are providing code changes, use the insert_edit_into_file tool (if availa
694694 },
695695 opts = {
696696 context_management = {
697- trigger = 0.75 , -- Compaction starts at 75% of the context window limit
698- enabled = function ( adapter )
699- if adapter . type ~= " http " then
700- return false
701- end
702- -- Anthropic and OpenAI have their own server-side compaction
703- if adapter . vendor and ( adapter . vendor == " anthropic " or adapter . vendor == " openai " ) then
704- return false
705- end
706- return true
707- end ,
697+ enabled = true , -- boolean, or function(adapter) -> boolean
698+ editing = {
699+ trigger = 0.65 , -- 65% of the context window
700+ keep = 5 , -- last N tool results stay intact
701+ exclude_tools = { " memory " }, -- tool names whose results never age out
702+ },
703+ compaction = {
704+ trigger = 0.85 , -- 85% of the context window
705+ adapter = nil , -- nil | string | { name = string, model = string }
706+ fallback_to_chat_adapter = false , -- on summary failure, retry with the chat adapter
707+ } ,
708708 },
709709
710710 blank_prompt = " " , -- The prompt to use when the user doesn't provide a prompt
@@ -1354,6 +1354,24 @@ M.setup = function(args)
13541354 M .config .interactions .chat .editor_context = nil
13551355 end
13561356
1357+ -- TODO: Deprecate in v20.0.0 and remove in v21.0.0
1358+ -- Legacy `context_management.trigger` migrates to `context_management.compaction.trigger`
1359+ local context_management = args .interactions
1360+ and args .interactions .chat
1361+ and args .interactions .chat .opts
1362+ and args .interactions .chat .opts .context_management
1363+ if context_management and context_management .trigger ~= nil then
1364+ vim .notify (
1365+ " [CodeCompanion] `context_management.trigger` is deprecated. Use `context_management.compaction.trigger` instead." ,
1366+ vim .log .levels .WARN ,
1367+ { title = " CodeCompanion" }
1368+ )
1369+ if not (context_management .compaction and context_management .compaction .trigger ~= nil ) then
1370+ M .config .interactions .chat .opts .context_management .compaction .trigger = context_management .trigger
1371+ end
1372+ M .config .interactions .chat .opts .context_management .trigger = nil
1373+ end
1374+
13571375 M .config .interactions .chat .keymaps = remove_disabled_keymaps (M .config .interactions .chat .keymaps )
13581376 M .config .interactions .cli .keymaps = remove_disabled_keymaps (M .config .interactions .cli .keymaps )
13591377 M .config .interactions .inline .keymaps = remove_disabled_keymaps (M .config .interactions .inline .keymaps )
0 commit comments