@@ -32,37 +32,49 @@ type ProviderConfig struct {
3232 // API Key is stored separately in CredentialStore, not in config
3333}
3434
35+ // CompactionConfig defines settings for context window management
36+ type CompactionConfig struct {
37+ AutoCompact bool `toml:"auto_compact"` // Whether to auto-compact when threshold reached
38+ AutoCompactThreshold float64 `toml:"auto_compact_threshold"` // Percentage (0.0-1.0) at which to trigger auto-compact
39+ KeepPercentage float64 `toml:"keep_percentage"` // Percentage (0.0-1.0) of context to keep when compacting
40+ WarnAtPercentage float64 `toml:"warn_at_percentage"` // Percentage (0.0-1.0) at which to show warning
41+ }
42+
3543type UserConfig struct {
36- DefaultProvider string `toml:"default_provider,omitempty"` // Which provider to use for new sessions
37- DefaultModel string `toml:"default_model,omitempty"` // Default model (moved from Ollama)
38- LastUsedProvider string `toml:"last_used_provider,omitempty"` // Last provider user switched to
39- Ollama OllamaConfig `toml:"ollama"`
40- DefaultSystemPrompt string `toml:"default_system_prompt,omitempty"`
41- PluginsEnabled bool `toml:"plugins_enabled"`
42- Security SecurityConfig `toml:"security"`
43- Providers []ProviderConfig `toml:"providers,omitempty"`
44- AllowedTools []string `toml:"allowed_tools,omitempty"` // Global whitelist of tools that don't require approval
45- RequireApproval bool `toml:"require_approval"` // Whether to ask for permission before executing tools
46- MaxIterations int `toml:"max_iterations"` // Default: 10
47- EnableMultiStep bool `toml:"enable_multi_step"` // Default: true
44+ DefaultProvider string `toml:"default_provider,omitempty"` // Which provider to use for new sessions
45+ DefaultModel string `toml:"default_model,omitempty"` // Default model (moved from Ollama)
46+ LastUsedProvider string `toml:"last_used_provider,omitempty"` // Last provider user switched to
47+ Ollama OllamaConfig `toml:"ollama"`
48+ DefaultSystemPrompt string `toml:"default_system_prompt,omitempty"`
49+ PluginsEnabled bool `toml:"plugins_enabled"`
50+ Security SecurityConfig `toml:"security"`
51+ Providers []ProviderConfig `toml:"providers,omitempty"`
52+ AllowedTools []string `toml:"allowed_tools,omitempty"` // Global whitelist of tools that don't require approval
53+ RequireApproval bool `toml:"require_approval"` // Whether to ask for permission before executing tools
54+ MaxIterations int `toml:"max_iterations"` // Default: 10
55+ EnableMultiStep bool `toml:"enable_multi_step"` // Default: true
56+ Compaction CompactionConfig `toml:"compaction,omitempty"` // Context window management settings
57+ ModelContextOverrides map [string ]int `toml:"model_context_overrides,omitempty"` // Per-model context window overrides
4858}
4959
5060type Config struct {
51- DataDirectory string
52- OllamaHost string
53- DefaultModel string
54- DefaultProvider string // Which provider to use for new sessions
55- LastUsedProvider string // Last provider user switched to
56- DefaultSystemPrompt string
57- PluginsEnabled bool
58- Security SecurityConfig
59- Providers []ProviderConfig
60- CredentialStore * CredentialStore
61- AllowedTools []string // Global whitelist of tools that don't require approval
62- RequireApproval bool // Whether to ask for permission before executing tools
63- MaxIterations int // Max iterations per user message
64- EnableMultiStep bool // Allow LLM to execute multiple steps
65- Keybindings * KeyBindingsConfig
61+ DataDirectory string
62+ OllamaHost string
63+ DefaultModel string
64+ DefaultProvider string // Which provider to use for new sessions
65+ LastUsedProvider string // Last provider user switched to
66+ DefaultSystemPrompt string
67+ PluginsEnabled bool
68+ Security SecurityConfig
69+ Providers []ProviderConfig
70+ CredentialStore * CredentialStore
71+ AllowedTools []string // Global whitelist of tools that don't require approval
72+ RequireApproval bool // Whether to ask for permission before executing tools
73+ MaxIterations int // Max iterations per user message
74+ EnableMultiStep bool // Allow LLM to execute multiple steps
75+ Compaction CompactionConfig // Context window management settings
76+ ModelContextOverrides map [string ]int // Per-model context window overrides
77+ Keybindings * KeyBindingsConfig
6678}
6779
6880var Debug = false
@@ -216,12 +228,25 @@ func Load() (*Config, error) {
216228 cfg .RequireApproval = userCfg .RequireApproval
217229 cfg .MaxIterations = userCfg .MaxIterations
218230 cfg .EnableMultiStep = userCfg .EnableMultiStep
231+ cfg .Compaction = userCfg .Compaction
232+ cfg .ModelContextOverrides = userCfg .ModelContextOverrides
219233
220234 // Set defaults for multi-step execution (Phase 2)
221235 if cfg .MaxIterations == 0 {
222236 cfg .MaxIterations = 10
223237 }
224238
239+ // Set defaults for compaction if not specified
240+ if cfg .Compaction .AutoCompactThreshold == 0 {
241+ cfg .Compaction .AutoCompactThreshold = 0.75
242+ }
243+ if cfg .Compaction .KeepPercentage == 0 {
244+ cfg .Compaction .KeepPercentage = 0.50
245+ }
246+ if cfg .Compaction .WarnAtPercentage == 0 {
247+ cfg .Compaction .WarnAtPercentage = 0.85
248+ }
249+
225250 // MIGRATION: Move Ollama.DefaultModel to top-level if needed
226251 if cfg .DefaultModel == "" && userCfg .Ollama .DefaultModel != "" {
227252 cfg .DefaultModel = userCfg .Ollama .DefaultModel
@@ -274,12 +299,25 @@ func Load() (*Config, error) {
274299 cfg .RequireApproval = userCfg .RequireApproval
275300 cfg .MaxIterations = userCfg .MaxIterations
276301 cfg .EnableMultiStep = userCfg .EnableMultiStep
302+ cfg .Compaction = userCfg .Compaction
303+ cfg .ModelContextOverrides = userCfg .ModelContextOverrides
277304
278305 // Set defaults for multi-step execution (Phase 2)
279306 if cfg .MaxIterations == 0 {
280307 cfg .MaxIterations = 10
281308 }
282309
310+ // Set defaults for compaction if not specified
311+ if cfg .Compaction .AutoCompactThreshold == 0 {
312+ cfg .Compaction .AutoCompactThreshold = 0.75
313+ }
314+ if cfg .Compaction .KeepPercentage == 0 {
315+ cfg .Compaction .KeepPercentage = 0.50
316+ }
317+ if cfg .Compaction .WarnAtPercentage == 0 {
318+ cfg .Compaction .WarnAtPercentage = 0.85
319+ }
320+
283321 // MIGRATION: Move Ollama.DefaultModel to top-level if needed
284322 if cfg .DefaultModel == "" && userCfg .Ollama .DefaultModel != "" {
285323 cfg .DefaultModel = userCfg .Ollama .DefaultModel
0 commit comments