Run compact session-start hooks before turn continuation (#34396)

## Why

Mid-turn auto-compaction queued `SessionStart` hooks but continued sampling
before running them. This delayed hook-provided context and ignored requests to
stop the continuation.

## What changed

Drain pending session-start hooks immediately after successful mid-turn
auto-compaction. End the turn when a hook requests a stop; otherwise include
its additional context in the next sampling request.

## Testing

Added coverage for repeated compactions in one turn, context delivery without
leaking hooks into the next user turn, and stop requests that block sampling.

GitOrigin-RevId: c57708a792fb47d98d95c38d7d91bcd9f235be84
This commit is contained in:
Andrei Eternal authored and copyberry committed 2026-07-20 19:08:58 +00:00
1 parent e4836f998d
commit 8c41ed33ce
2 files changed
+274

No files matched your search

+3
View File
@@ -371,6 +371,9 @@ pub(crate) async fn run_turn(
.await;
return Ok(None);
}
if run_pending_session_start_hooks(&sess, &turn_context).await {
return Ok(None);
}
can_drain_pending_input = !model_needs_follow_up;
continue;
}