Repository navigation
Python: Fix Ollama streaming finish reason for tool calls - #9763
Dhruv Shaswat (Dhruv-Sh-git) wants to merge 2 commits into
Conversation
|
@microsoft-github-policy-service agree |
|
/review |
There was a problem hiding this comment.
MAF Automated Review — Iteration 1
Result: Findings reported
Scope: full PR (1 commit(s)): f5e11a1ac449
Model: gpt-5.6-sol
Overview
The change correctly keeps tool-call presence request-local, reports the synthesized reason only on the terminal chunk, and retains existing stream cleanup and content-based tool execution. The new regression test covers the reported tool-call-then-stop sequence. However, the same historical flag also overwrites meaningful non-stop terminal reasons such as length, so one Medium contract issue remains.
Reviewed the supplied pull-request change set across correctness, security/reliability, architecture, and failure behavior.
1 verified finding remained after source verification (1 medium) across 1 file. Details are attached to the affected lines below.
Affected areas: python/packages/ollama/agent_framework_ollama/_chat_client.py
55d352a to
7dcc5fd
Compare
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.