From 6257983449ddf6f0fe0df7d57e845e29566a85d3 Mon Sep 17 00:00:00 2001 From: max-montes <77820353+max-montes@users.noreply.github.com> Date: Mon, 2 Mar 2026 14:09:45 -0800 Subject: [PATCH 1/4] Fix OllamaChatClient passing unsupported kwargs to ollama.AsyncClient.chat() Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../agent_framework_ollama/_chat_client.py | 4 +- .../ollama/tests/test_ollama_chat_client.py | 56 +++++++++++++++++++ 2 files changed, 57 insertions(+), 3 deletions(-) diff --git a/python/packages/ollama/agent_framework_ollama/_chat_client.py b/python/packages/ollama/agent_framework_ollama/_chat_client.py index cc7fc0c9a7..a18ca05c12 100644 --- a/python/packages/ollama/agent_framework_ollama/_chat_client.py +++ b/python/packages/ollama/agent_framework_ollama/_chat_client.py @@ -349,7 +349,7 @@ def _inner_get_response( messages: Sequence[Message], options: Mapping[str, Any], stream: bool = False, - **kwargs: Any, + **kwargs: Any, # noqa: ARG002 — accepted for interface compatibility; not forwarded to Ollama ) -> Awaitable[ChatResponse] | ResponseStream[ChatResponseUpdate, ChatResponse]: if stream: # Streaming mode @@ -360,7 +360,6 @@ async def _stream() -> AsyncIterable[ChatResponseUpdate]: response_object: AsyncIterable[OllamaChatResponse] = await self.client.chat( # type: ignore[misc] stream=True, **options_dict, - **kwargs, ) except Exception as ex: raise ChatClientException(f"Ollama streaming chat request failed : {ex}", ex) from ex @@ -378,7 +377,6 @@ async def _get_response() -> ChatResponse: response: OllamaChatResponse = await self.client.chat( # type: ignore[misc] stream=False, **options_dict, - **kwargs, ) except Exception as ex: raise ChatClientException(f"Ollama chat request failed : {ex}", ex) from ex diff --git a/python/packages/ollama/tests/test_ollama_chat_client.py b/python/packages/ollama/tests/test_ollama_chat_client.py index 490bbc0a15..57406a6819 100644 --- a/python/packages/ollama/tests/test_ollama_chat_client.py +++ b/python/packages/ollama/tests/test_ollama_chat_client.py @@ -248,6 +248,62 @@ async def test_cmc( assert result.text == "test" +@patch.object(AsyncClient, "chat", new_callable=AsyncMock) +async def test_cmc_ignores_unsupported_kwargs( + mock_chat: AsyncMock, + ollama_unit_test_env: dict[str, str], + chat_history: list[Message], + mock_chat_completion_response: OllamaChatResponse, +) -> None: + """Verify that unsupported kwargs (e.g. allow_multiple_tool_calls) are + silently filtered out and never forwarded to ollama.AsyncClient.chat(). + + Regression test for: https://github.com/microsoft/agent-framework/issues/4402 + """ + mock_chat.return_value = mock_chat_completion_response + chat_history.append(Message(text="hello world", role="user")) + + ollama_client = OllamaChatClient() + result = await ollama_client.get_response( + messages=chat_history, + allow_multiple_tool_calls=True, + ) + + assert result.text == "test" + mock_chat.assert_called_once() + call_kwargs = mock_chat.call_args.kwargs + assert "allow_multiple_tool_calls" not in call_kwargs + + +@patch.object(AsyncClient, "chat", new_callable=AsyncMock) +async def test_cmc_streaming_ignores_unsupported_kwargs( + mock_chat: AsyncMock, + ollama_unit_test_env: dict[str, str], + chat_history: list[Message], + mock_streaming_chat_completion_response: AsyncStream[OllamaChatResponse], +) -> None: + """Verify that unsupported kwargs are filtered in streaming mode too. + + Regression test for: https://github.com/microsoft/agent-framework/issues/4402 + """ + mock_chat.return_value = mock_streaming_chat_completion_response + chat_history.append(Message(text="hello world", role="user")) + + ollama_client = OllamaChatClient() + result = ollama_client.get_response( + messages=chat_history, + stream=True, + allow_multiple_tool_calls=True, + ) + + async for chunk in result: + assert chunk.text == "test" + + mock_chat.assert_called_once() + call_kwargs = mock_chat.call_args.kwargs + assert "allow_multiple_tool_calls" not in call_kwargs + + @patch.object(AsyncClient, "chat", new_callable=AsyncMock) async def test_cmc_reasoning( mock_chat: AsyncMock, From af23914dfc0ae24b7fb38f229aee4fbad7fe1fad Mon Sep 17 00:00:00 2001 From: max-montes <77820353+max-montes@users.noreply.github.com> Date: Tue, 3 Mar 2026 11:25:32 -0800 Subject: [PATCH 2/4] ci: retrigger checks From 60d81fbd6f03a8fb0b22b58fe21b8be35a8ebc7a Mon Sep 17 00:00:00 2001 From: max-montes <77820353+max-montes@users.noreply.github.com> Date: Tue, 3 Mar 2026 11:31:15 -0800 Subject: [PATCH 3/4] ci: retrigger checks (GitHub 500 on checkout) From 94091be65d55e0acfb80239b0b8614b0dfc29d50 Mon Sep 17 00:00:00 2001 From: max-montes <77820353+max-montes@users.noreply.github.com> Date: Tue, 3 Mar 2026 12:39:34 -0800 Subject: [PATCH 4/4] ci: retrigger checks (post-outage)