CodeWhale icon indicating copy to clipboard operation
CodeWhale copied to clipboard

fix(compaction): default off + raise unknown-model floor to 80% (#664, v0.8.11)

Open Hmbown opened this issue 6 months ago • 1 comments

Summary

Stops the engine from routinely rewriting the prompt prefix, which burns DeepSeek V4's prefix-cache discount and is the dominant cost-spike vector in long sessions. Two coordinated changes for v0.8.11.

Change 1 — auto_compact default flips to false

crates/tui/src/settings.rs. Pre-v0.8.11 default was true (#402 P0 "session survivability"); under V4 the same default behaviour costs ~10× per post-compaction turn because the rewritten prefix invalidates the cache. With V4's 1M-token window the user has enough headroom to run long sessions without auto-trimming, and the explicit /compact command + auto_compact = on opt-in remain available for workloads that prefer compaction over cache stability.

Change 2 — DEFAULT_COMPACTION_TOKEN_THRESHOLD raised from 50_000 to 102_400

crates/tui/src/models.rs. This is the last-resort threshold when context_window_for_model returns None (unrecognised model id). The legacy 50_000 value was set when 128K was the headline window — under V4 it works out to compacting at ~5% of the actual context budget when model detection falls through, which is exactly the prefix-cache-burning behaviour we're getting away from. The new floor is 80% of DEFAULT_CONTEXT_WINDOW_TOKENS = 128_000, matching the discipline applied to all known model paths.

What this is NOT

  • Not the agent-aware-handoff pattern in #664 (that's a much larger design surface — out of v0.8.11 scope; this PR closes the immediate cache cost while #664 stays open as the long-term fix).
  • Not removing compaction entirely. The /compact slash command, the auto_compact = on opt-in, and the runtime-thread / capacity-flow / cycle-manager auto-compaction paths all remain functional. We're just changing the default for the in-TUI session.

Test plan

  • [x] cargo fmt --all -- --check clean.
  • [x] cargo clippy -p deepseek-tui --bin deepseek-tui --all-features --locked -- -D warnings clean.
  • [x] cargo test -p deepseek-tui --bin deepseek-tui --locked → 2028 passed, 2 ignored.
  • [x] Updated test names + inline comments explain the new defaults so a future maintainer doesn't accidentally restore the old values without reading the rationale.
  • [ ] Manual: launch a long session on V4, confirm no auto-compaction fires until the user invokes /compact explicitly. (Verify RUST_LOG=compaction=debug shows zero Auto-compacting context... events on default config.)
  • [ ] Manual: set auto_compact = on in ~/.deepseek/settings.toml, confirm the old auto-trigger behaviour still works for users who opt in.

🤖 Generated with Claude Code

Hmbown avatar May 05 '26 00:05 Hmbown

[!WARNING] You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

gemini-code-assist avatar May 05 '26 00:05 gemini-code-assist