mirror of
https://github.com/openai/codex.git
synced 2026-11-08 20:40:33 +00:00
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:
@@ -140,7 +140,11 @@ impl SampleTask {
|
||||
ThreadHistoryMode::Legacy => build_legacy_api_turns_from_rollout_items(&history.items)
|
||||
.last()
|
||||
.is_some_and(|turn| {
|
||||
turn.id == params.expected_turn_id && turn.status == TurnStatus::Completed
|
||||
turn.id == params.expected_turn_id
|
||||
&& matches!(
|
||||
turn.status,
|
||||
TurnStatus::Completed | TurnStatus::Failed | TurnStatus::Interrupted
|
||||
)
|
||||
}),
|
||||
ThreadHistoryMode::Paginated => store
|
||||
.list_turns(ListTurnsParams {
|
||||
@@ -157,12 +161,17 @@ impl SampleTask {
|
||||
.first()
|
||||
.is_some_and(|turn| {
|
||||
turn.turn_id == params.expected_turn_id
|
||||
&& turn.status == StoredTurnStatus::Completed
|
||||
&& matches!(
|
||||
turn.status,
|
||||
StoredTurnStatus::Completed
|
||||
| StoredTurnStatus::Failed
|
||||
| StoredTurnStatus::Interrupted
|
||||
)
|
||||
}),
|
||||
};
|
||||
if !matches_source {
|
||||
return Err(invalid_request(
|
||||
"sample source turn is no longer the latest completed turn",
|
||||
"sample source turn must be the latest finished turn",
|
||||
));
|
||||
}
|
||||
let (mut options, settings) = Box::pin(async {
|
||||
|
||||
Reference in New Issue
Block a user