Allow thread sampling after failed or interrupted turns (#56020)

## Why

`thread/sample` previously required the latest source turn to have completed successfully, rejecting failed or interrupted turns even when the source was idle.

## What changed

Accept the latest completed, failed, or interrupted turn in both legacy and paginated history modes. Update the protocol documentation and validation error to reflect the accepted statuses, while continuing to reject stale or active sources.

## Testing

Expand integration coverage across all three terminal statuses and both history modes, checking that sampling preserves context and leaves the source unchanged. Also verify that sampling an active source is rejected before interrupting it.

GitOrigin-RevId: a5dfdb2800868ee178eae16b12ee7f6f9515898c
This commit is contained in:
liame-oai
2026-10-22 00:06:08 +00:00
committed by copyberry
parent aafd81a7ad
commit 6f34d3d408
4 changed files with 77 additions and 27 deletions
@@ -12,7 +12,8 @@ use serde::Serialize;
#[ts(export_to = "v2/")]
pub struct ThreadSampleParams {
pub thread_id: String,
/// The loaded source's latest completed turn. Stale or active sources are rejected.
/// The loaded source's latest completed, failed, or interrupted turn.
/// Stale or active sources are rejected.
pub expected_turn_id: String,
pub prompt: String,
/// Applied only when the provider and model support cache-preserving reasoning-effort updates.