Pre-sampling compact with previous model context (#11504)

- Run pre-sampling compact through a single helper that builds
previous-model turn context and compacts before the follow-up request
when switching to a smaller context window.
- Keep compaction events on the parent turn id and add compact suite
coverage for switch-in-session and resume+switch flows.
This commit is contained in:
Ahmed Ibrahim
2026-02-11 17:24:06 -08:00
committed by GitHub
parent 3f1b41689a
commit 6938150c5e
3 changed files with 500 additions and 4 deletions

View File

@@ -153,7 +153,7 @@ impl Session {
if !task_cancellation_token.is_cancelled() {
// Emit completion uniformly from spawn site so all tasks share the same lifecycle.
let sess = session_ctx.clone_session();
sess.on_task_finished(ctx_for_finish, last_agent_message)
sess.on_task_finished(Arc::clone(&ctx_for_finish), last_agent_message)
.await;
}
// Set previous model regardless of completion or interruption for model-switch handling.