feat(engine): context-limit handoff thresholds (closes #664)

This commit is contained in:
wangfeng
2026-05-04 18:05:34 -07:00
parent 3cff070570
commit 401b563346
3 changed files with 14 additions and 0 deletions
+5
View File
@@ -25,6 +25,10 @@ pub struct CompactionConfig {
pub message_threshold: usize,
pub model: String,
pub cache_summary: bool,
/// When `Some(true)`, the engine prefers writing a handoff file over
/// running LLM-based compaction when context pressure triggers.
/// `None` / `Some(false)` means default compaction behaviour.
pub prefer_handoff: Option<bool>,
}
impl Default for CompactionConfig {
@@ -40,6 +44,7 @@ impl Default for CompactionConfig {
message_threshold: 50,
model: DEFAULT_TEXT_MODEL.to_string(),
cache_summary: true,
prefer_handoff: None,
}
}
}
+8
View File
@@ -0,0 +1,8 @@
pub const THRESHOLDS: [(f32, &str); 3] = [
(0.9, "Context at 90%: stop and write handoff to .deepseek/handoff.md now"),
(0.8, "Context at 80%: draft handoff to .deepseek/handoff.md"),
(0.7, "Context at 70%: consider wrapping current sub-task"),
];
pub fn threshold_message(ratio: f32) -> Option<&'static str> {
THRESHOLDS.iter().find(|(t,_)| ratio >= *t).map(|(_,m)| *m)
}
+1
View File
@@ -30,6 +30,7 @@ mod error_taxonomy;
mod eval;
mod execpolicy;
mod features;
mod handoff;
mod hooks;
mod llm_client;
mod localization;