Fix flaky pre_sampling_compact switch test (#11573)

Summary
- address the nondeterministic behavior observed in
`pre_sampling_compact_runs_on_switch_to_smaller_context_model` so it no
longer fails intermittently during model switches
- ensure the surrounding sampling logic consistently handles the
smaller-context case that the test exercises

Testing
- Not run (not requested)
This commit is contained in:
jif-oai 2026-02-12 11:40:48 +00:00 committed by GitHub
parent a0dab25c68
commit 3cd93c00ac
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -149,18 +149,16 @@ impl Session {
task_cancellation_token.child_token(),
)
.await;
session_ctx.clone_session().flush_rollout().await;
let sess = session_ctx.clone_session();
sess.flush_rollout().await;
// Update previous model before TurnComplete is emitted so
// immediately following turns observe the correct switch state.
sess.set_previous_model(Some(model_slug)).await;
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(Arc::clone(&ctx_for_finish), last_agent_message)
.await;
}
// Set previous model regardless of completion or interruption for model-switch handling.
session_ctx
.clone_session()
.set_previous_model(Some(model_slug))
.await;
done_clone.notify_waiters();
}
.instrument(session_span),