mirror of
https://github.com/instructkr/claude-code.git
synced 2026-05-26 07:26:46 +00:00
fix: auto_compact runs before every iteration break, including terminal no-tool turns; closes #3106
This commit is contained in:
@@ -342,6 +342,7 @@ where
|
||||
let mut tool_results = Vec::new();
|
||||
let mut prompt_cache_events = Vec::new();
|
||||
let mut iterations = 0;
|
||||
let mut auto_compaction = None;
|
||||
|
||||
loop {
|
||||
iterations += 1;
|
||||
@@ -397,6 +398,12 @@ where
|
||||
.map_err(|error| RuntimeError::new(error.to_string()))?;
|
||||
assistant_messages.push(assistant_message);
|
||||
|
||||
// Run auto-compaction check before next API call, including on the terminal
|
||||
// (no-tool) iteration, to prevent unbounded session growth (#3106).
|
||||
if let Some(compaction) = self.maybe_auto_compact() {
|
||||
auto_compaction = Some(compaction);
|
||||
}
|
||||
|
||||
if pending_tool_uses.is_empty() {
|
||||
break;
|
||||
}
|
||||
@@ -503,8 +510,6 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
let auto_compaction = self.maybe_auto_compact();
|
||||
|
||||
let summary = TurnSummary {
|
||||
assistant_messages,
|
||||
tool_results,
|
||||
|
||||
Reference in New Issue
Block a user