mirror of
https://github.com/instructkr/claude-code.git
synced 2026-05-28 08:26:45 +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 tool_results = Vec::new();
|
||||||
let mut prompt_cache_events = Vec::new();
|
let mut prompt_cache_events = Vec::new();
|
||||||
let mut iterations = 0;
|
let mut iterations = 0;
|
||||||
|
let mut auto_compaction = None;
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
iterations += 1;
|
iterations += 1;
|
||||||
@@ -397,6 +398,12 @@ where
|
|||||||
.map_err(|error| RuntimeError::new(error.to_string()))?;
|
.map_err(|error| RuntimeError::new(error.to_string()))?;
|
||||||
assistant_messages.push(assistant_message);
|
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() {
|
if pending_tool_uses.is_empty() {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -503,8 +510,6 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let auto_compaction = self.maybe_auto_compact();
|
|
||||||
|
|
||||||
let summary = TurnSummary {
|
let summary = TurnSummary {
|
||||||
assistant_messages,
|
assistant_messages,
|
||||||
tool_results,
|
tool_results,
|
||||||
|
|||||||
Reference in New Issue
Block a user