Support end_turn in response.completed (#19610)

Some providers of Responses API forward a model-defined `end_turn`
boolean indicating explicitly the model's indication of whether it would
like to end the turn or to be inferenced again. In this PR, we update
the sampling loop to use this field correctly if it's set. If the field
is not set by the provider, we fall back to the existing sampling logic.
This commit is contained in:
Andrey Mishchenko
2026-04-25 21:57:42 -07:00
committed by GitHub
parent 5591912f0b
commit 355c40ad7e
7 changed files with 44 additions and 7 deletions
+4 -1
View File
@@ -2132,6 +2132,7 @@ async fn try_run_sampling_request(
ResponseEvent::Completed {
response_id: _,
token_usage,
end_turn,
} => {
flush_assistant_text_segments_all(
&sess,
@@ -2143,7 +2144,9 @@ async fn try_run_sampling_request(
sess.update_token_usage_info(&turn_context, token_usage.as_ref())
.await;
should_emit_turn_diff = true;
if let Some(false) = end_turn {
needs_follow_up = true;
}
break Ok(SamplingRequestResult {
needs_follow_up,
last_agent_message,