Skip to content

Python: Fix Ollama streaming finish reason for tool calls - #9763

Open
Dhruv Shaswat (Dhruv-Sh-git) wants to merge 1 commit into
microsoft:mainfrom
Dhruv-Sh-git:fix/issue-9676
Open

Dhruv Shaswat (Dhruv-Sh-git) wants to merge 1 commit into
microsoft:mainfrom
Dhruv-Sh-git:fix/issue-9676

Conversation

@Dhruv-Sh-git

@Dhruv-Sh-git Dhruv Shaswat (Dhruv-Sh-git) commented Oct 27, 2026 •

Copy link
Copy Markdown

Fixes #9676. This change keeps track of whether a tool call appeared during streaming and uses that information when parsing the final response. I also added a regression test for this case. Track tool calls across Ollama streaming chunks so the final response reports finish_reason='tool_calls' instead of 'stop'. Add a regression test covering a tool call in a non-terminal chunk followed by a terminal chunk without tool calls. This contribution was developed with AI assistance. The changes and tests were reviewed and validated locally.

Copilot AI balanced review requested due to automatic review settings October 27, 2026 13:21

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@agent-framework-automation agent-framework-automation Bot added the python Usage: [Issues, PRs], Target: Python label Oct 27, 2026
@github-actions github-actions Bot changed the title Fix Ollama streaming finish reason for tool calls Python: Fix Ollama streaming finish reason for tool calls Oct 27, 2026
@Dhruv-Sh-git

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

This branch was successfully deployed

1 active deployment
github-app-auth — f5e11a1a Deployed Oct 27, 2026 by Dhruv-Sh-git via team_check #7719
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: [Bug]: Ollama streaming reports finish_reason "stop" when the turn is a tool call

2 participants