Retain the last selected step context for each turn (#41429)

## What changed

- Store the most recently captured execution `StepContext` in the active turn state.
- Keep speculative model-fallback captures from replacing that context, and update it only when the fallback is selected for remote compaction.
- Preserve the retained context when a turn completes or is interrupted.

## Testing

- Add coverage for completed and interrupted turns, successful primary compaction, fallback compaction, and interruption while a fallback is running.

GitOrigin-RevId: c7dee36ec8e88ba2f4fb4a9c0322e5c86a0caf0e
This commit is contained in:
Krish Chainani authored and copyberry committed 2026-08-28 22:26:23 +00:00
1 parent 2008d27e98
commit 0d22692962
7 files changed
+356 -36

No files matched your search

+1 -1
View File
@@ -1088,7 +1088,7 @@ async fn capture_current_model_fallback_step_context(
{
return Ok(None);
}
sess.capture_step_context(Arc::clone(turn_context), cancellation_token)
sess.capture_speculative_step_context(Arc::clone(turn_context), cancellation_token)
.await
.map(Some)
}