This commit is contained in:
0x11 2025-08-26 19:08:31 +02:00 committed by GitHub
commit 48c6699a56
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -609,7 +609,15 @@ impl OpenAiEventMapper {
}
}
match choice.finish_reason.as_deref() {
let mut effective_finish_reason = choice.finish_reason.as_deref();
if effective_finish_reason == Some("stop") && !self.tool_calls_by_index.is_empty()
{
log::warn!("finish_reason is 'stop' but tool calls are present; inferring 'tool_calls'");
effective_finish_reason = Some("tool_calls");
}
match effective_finish_reason {
Some("stop") => {
events.push(Ok(LanguageModelCompletionEvent::Stop(StopReason::EndTurn)));
}