[PR #7963] [MERGED] openai: finish streaming tool calls as tool_calls #38446

Closed
opened 2026-04-22 23:06:51 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/7963
Author: @anuraaga
Created: 12/6/2024
Status: Merged
Merged: 2/13/2025
Merged by: @ParthSareen

Base: mainHead: stream-tools-stop


📝 Commits (5)

📊 Changes

1 file changed (+11 additions, -2 deletions)

View changed files

📝 openai/openai.go (+11 -2)

📄 Description

When a response contains tool_calls it finishes the chat, and we see this already happening in Ollama in non-chunk mode. This ensures that the chunk with tool calls contains the finish reason, not a following one, while any following ones are not sent - their choice with empty content will conflict with the tool call response. This follows how OpenAI API behaves as far as I can tell.

/cc @codefromthecrypt


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ollama/ollama/pull/7963 **Author:** [@anuraaga](https://github.com/anuraaga) **Created:** 12/6/2024 **Status:** ✅ Merged **Merged:** 2/13/2025 **Merged by:** [@ParthSareen](https://github.com/ParthSareen) **Base:** `main` ← **Head:** `stream-tools-stop` --- ### 📝 Commits (5) - [`94264e1`](https://github.com/ollama/ollama/commit/94264e12c4d55e73ac4d1acbb2570c64765f63da) Use last chunk for finish reason - [`6bfa937`](https://github.com/ollama/ollama/commit/6bfa9374985d11a3bc761f32d0604abcea1c1edf) Merge branch 'main' of https://github.com/ollama/ollama into stream-tools-stop - [`fa6c4ec`](https://github.com/ollama/ollama/commit/fa6c4ecb1551f95a86fe55f891d35198af89f4ed) Merge branch 'main' of https://github.com/ollama/ollama into stream-tools-stop - [`e1aff9c`](https://github.com/ollama/ollama/commit/e1aff9c26b0166bd426eaa79400bf6a365500be2) Rename - [`6597e68`](https://github.com/ollama/ollama/commit/6597e683201f931123c699d308ee5a97381b6128) Rename more ### 📊 Changes **1 file changed** (+11 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `openai/openai.go` (+11 -2) </details> ### 📄 Description When a response contains tool_calls it finishes the chat, and we see this already happening in Ollama in non-chunk mode. This ensures that the chunk with tool calls contains the finish reason, not a following one, while any following ones are not sent - their choice with empty content will conflict with the tool call response. This follows how OpenAI API behaves as far as I can tell. /cc @codefromthecrypt --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-22 23:06:51 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#38446