[PR #9938] [CLOSED] server/routes: stream both tool call and content #13103

Closed
opened 2026-04-13 00:18:07 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/9938
Author: @8LWXpg
Created: 3/22/2025
Status: Closed

Base: mainHead: stream


📝 Commits (1)

  • 7398459 stream both tool call and content

📊 Changes

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

View changed files

📝 server/routes.go (+1 -11)

📄 Description

An attempt to fix #7886 and #9632, with potential API breaking change.

As noted by ParthSareen in https://github.com/ollama/ollama/issues/8887#issuecomment-2640721896, the current implementation ensures that content and tool_calls cannot coexist. When no tool_call is present, Ollama returns the content as a single chunk.

This PR stream both tool_calls and content, ensuring content stream is available even if no tool call is parsed, which means you'll get tool_calls alongside with content.

The impact might be minimal, since we can ignore content all alone when handling tool call response, same as the current implementation assumes adding tools only when you expect the model to use it,

Anyway, more input is definitely needed on this change to ensure it addresses the broader range of use cases with minimal side effect.

Demo from MCP client with qwen2.5:0.5b:

https://github.com/user-attachments/assets/302435ee-d3eb-4394-8b5a-a1ddb6848d1e


🔄 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/9938 **Author:** [@8LWXpg](https://github.com/8LWXpg) **Created:** 3/22/2025 **Status:** ❌ Closed **Base:** `main` ← **Head:** `stream` --- ### 📝 Commits (1) - [`7398459`](https://github.com/ollama/ollama/commit/7398459026a661ea61b72a53ce0b4b1d2451b969) stream both tool call and content ### 📊 Changes **1 file changed** (+1 additions, -11 deletions) <details> <summary>View changed files</summary> 📝 `server/routes.go` (+1 -11) </details> ### 📄 Description An attempt to fix #7886 and #9632, with potential API breaking change. As noted by [ParthSareen](https://github.com/ParthSareen) in https://github.com/ollama/ollama/issues/8887#issuecomment-2640721896, the current implementation ensures that `content` and `tool_calls` cannot coexist. When no `tool_call` is present, Ollama returns the content as a single chunk. This PR stream both `tool_calls` and `content`, ensuring `content` stream is available even if no tool call is parsed, which means you'll get `tool_calls` alongside with `content`. The impact might be minimal, since we can ignore `content` all alone when handling tool call response, same as the current implementation assumes adding tools only when you expect the model to use it, Anyway, more input is definitely needed on this change to ensure it addresses the broader range of use cases with minimal side effect. Demo from MCP client with qwen2.5:0.5b: https://github.com/user-attachments/assets/302435ee-d3eb-4394-8b5a-a1ddb6848d1e --- <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-13 00:18:07 -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#13103