You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
At ~99.6% context saturation, the TUI becomes completely unresponsive (no keypresses, no UI updates) while the model is mid-turn. The status bar shows Memory 100% and Context 995.8K / 1M tokens, but the TUI event loop is effectively starved.
Root Cause
Two independent guardrails are both disabled by default since v0.8.11:
Layer
Setting
Default
Effect when OFF
Capacity controller
[capacity].enabled
false
No TargetedContextRefresh, no VerifyAndReplan
Compaction subsystem
auto_compact
false
should_compact() returns false unconditionally
With both disabled, the only compaction trigger is the model suggesting /compact in its response — which becomes impossible at ~99.6% context saturation (chicken-and-egg deadlock).
Additionally, the pre-send auto-compact check (should_auto_compact_before_send()) fires at 95% (CONTEXT_CRITICAL_THRESHOLD_PERCENT), which is already in the danger zone where the model struggles to produce tokens. The system prompt tells the model to suggest /compact at 60%, but the engine does nothing automatic at that threshold.
Solution
This PR adds a configurable auto-compact threshold and a manual compaction keybinding, closing the gap between model guidance and engine action.
Changes
New auto_compact_threshold_percent setting (default 70%)
Configurable via config.toml or /set auto_compact_threshold 70 --save
Validated to range 10–100
Respects the existing 500K-token hard floor (MINIMUM_AUTO_COMPACTION_TOKENS) so small sessions are never auto-compacted
should_auto_compact_before_send() now uses the configurable threshold
Was: hardcoded to 95% (CONTEXT_CRITICAL_THRESHOLD_PERCENT)
Compaction fires before the danger zone, while the model is still responsive
Early context-pressure warning at 60%
New CONTEXT_SUGGEST_COMPACT_THRESHOLD_PERCENT = 60.0
Non-intrusive status message: "Context building: 60% — Consider enabling auto_compact or use /compact."
Only shows when status_message is empty (never stomps on more important messages)
Ctrl+L keybinding for manual compaction
Works even when the model is mid-turn (streaming)
Breaks the chicken-and-egg deadlock: user can compact without model assistance
Status: "Compacting context (Ctrl+L)..."
Updated system prompt guidance
Model now knows about auto-compact threshold and Ctrl+L
"If auto_compact is enabled, the engine will automatically compact before the next send when context crosses the configured threshold (default 70%). The user can also press Ctrl+L at any time."
Files Changed
File
Lines
Description
crates/tui/src/settings.rs
+25
New field, default, set handler with validation, help text
crates/tui/src/tui/app.rs
+3
auto_compact_threshold_pct field + wiring from settings
crates/tui/src/tui/ui.rs
+49
Constants, maybe_warn_context_pressure() early warning, should_auto_compact_before_send() configurable threshold, Ctrl+L keybinding
crates/tui/src/prompts.rs
+1/-1
System prompt updates
Configuration
# ~/.deepseek/config.tomlauto_compact = true# master switch (still defaults to false)auto_compact_threshold_percent = 70# fires at 70% (NEW — default 70)
Problem
At ~99.6% context saturation, the TUI becomes completely unresponsive (no keypresses, no UI updates) while the model is mid-turn. The status bar shows Memory 100% and Context 995.8K / 1M tokens, but the TUI event loop is effectively starved.
Root Cause
Two independent guardrails are both disabled by default since v0.8.11:
[capacity].enabledfalseauto_compactfalseshould_compact()returnsfalseunconditionallyWith both disabled, the only compaction trigger is the model suggesting
/compactin its response — which becomes impossible at ~99.6% context saturation (chicken-and-egg deadlock).Additionally, the pre-send auto-compact check (
should_auto_compact_before_send()) fires at 95% (CONTEXT_CRITICAL_THRESHOLD_PERCENT), which is already in the danger zone where the model struggles to produce tokens. The system prompt tells the model to suggest/compactat 60%, but the engine does nothing automatic at that threshold.Solution
This PR adds a configurable auto-compact threshold and a manual compaction keybinding, closing the gap between model guidance and engine action.
Changes
New
auto_compact_threshold_percentsetting (default 70%)config.tomlor/set auto_compact_threshold 70 --saveMINIMUM_AUTO_COMPACTION_TOKENS) so small sessions are never auto-compactedshould_auto_compact_before_send()now uses the configurable thresholdCONTEXT_CRITICAL_THRESHOLD_PERCENT)app.auto_compact_threshold_pct(default 70%) + checks 500K floorEarly context-pressure warning at 60%
CONTEXT_SUGGEST_COMPACT_THRESHOLD_PERCENT = 60.0status_messageis empty (never stomps on more important messages)Ctrl+L keybinding for manual compaction
Updated system prompt guidance
Files Changed
crates/tui/src/settings.rscrates/tui/src/tui/app.rsauto_compact_threshold_pctfield + wiring from settingscrates/tui/src/tui/ui.rsmaybe_warn_context_pressure()early warning,should_auto_compact_before_send()configurable threshold, Ctrl+L keybindingcrates/tui/src/prompts.rsConfiguration
Or in-session:
Behavior Flow
Backward Compatibility
auto_compactstill defaults tofalse— existing users see no changeauto_compact_threshold_percentdefaults to 70.0 — only active whenauto_compact = true/compactslash command unchangedRelated