Ensure auto-compaction starts after turn started (#10129)

Start auto-compaction only after TurnStarted is emitted.\nAdd an
integration test for deterministic ordering.
This commit is contained in:
Ahmed Ibrahim authored and GitHub committed 2026-01-28 16:51:20 -08:00
1 parent 8497163363
commit 26590d7927
2 files changed
+98 -3

No files matched your search

+3 -3
View File
@@ -3151,13 +3151,13 @@ pub(crate) async fn run_turn(
let model_info = turn_context.client.get_model_info();
let auto_compact_limit = model_info.auto_compact_token_limit().unwrap_or(i64::MAX);
let total_usage_tokens = sess.get_total_token_usage().await;
if total_usage_tokens >= auto_compact_limit {
run_auto_compact(&sess, &turn_context).await;
}
let event = EventMsg::TurnStarted(TurnStartedEvent {
model_context_window: turn_context.client.get_model_context_window(),
});
sess.send_event(&turn_context, event).await;
if total_usage_tokens >= auto_compact_limit {
run_auto_compact(&sess, &turn_context).await;
}
let skills_outcome = Some(
sess.services