From 3902bbcf7edd88dbe6f3f0d99c2feb6b20f08c9f Mon Sep 17 00:00:00 2001 From: kshitijk4poor <82637225+kshitijk4poor@users.noreply.github.com> Date: Thu, 8 Oct 2026 00:00:26 +0530 Subject: [PATCH] test: move the profile-hook keyword compat test into its own module test_chat_completions.py grew past the 1,000-line test-file guideline with #134320's TestProfileHookKeywordCompat (1,006 lines). The test pins the transport's hook-call contract, not response handling, so it moves verbatim to test_profile_hook_keyword_compat.py (985 lines left). Reported by the review bot on #134320. --- .../agent/transports/test_chat_completions.py | 21 ------------ .../test_profile_hook_keyword_compat.py | 33 +++++++++++++++++++ 2 files changed, 33 insertions(+), 21 deletions(-) create mode 100644 tests/agent/transports/test_profile_hook_keyword_compat.py diff --git a/tests/agent/transports/test_chat_completions.py b/tests/agent/transports/test_chat_completions.py index 0180ffc95f..7eaccba996 100644 --- a/tests/agent/transports/test_chat_completions.py +++ b/tests/agent/transports/test_chat_completions.py @@ -546,27 +546,6 @@ class TestChatCompletionsLmStudioReasoning: assert kw["reasoning_effort"] == "high" - - - -class TestProfileHookKeywordCompat: - """``lmstudio_reasoning_options`` is LM Studio-only: a plugin hook that names the older keywords - without ``**context`` must not start raising TypeError on every request.""" - - def test_hook_without_var_kwargs_still_called(self, transport): - from providers.base import ProviderProfile - - class OldSignature(ProviderProfile): - def build_api_kwargs_extras(self, *, reasoning_config=None, supports_reasoning=False, - qwen_session_metadata=None, model=None, base_url=None, - ollama_num_ctx=None, session_id=None, cache_scope_id=None): - return {}, {"reasoning_effort": "low"} - - kw = transport.build_kwargs(model="m", messages=[{"role": "user", "content": "Hi"}], - provider_profile=OldSignature(name="old-signature")) - assert kw["reasoning_effort"] == "low" - - class TestChatCompletionsValidate: def test_none(self, transport): diff --git a/tests/agent/transports/test_profile_hook_keyword_compat.py b/tests/agent/transports/test_profile_hook_keyword_compat.py new file mode 100644 index 0000000000..8ac1704b19 --- /dev/null +++ b/tests/agent/transports/test_profile_hook_keyword_compat.py @@ -0,0 +1,33 @@ +"""A plugin profile's ``build_api_kwargs_extras`` written against the older keyword set keeps working. + +Split from ``test_chat_completions.py`` (size cap): this pins the transport's hook-call contract, +not response handling. +""" + +import pytest + +from agent.transports import get_transport + + +@pytest.fixture +def transport(): + import agent.transports.chat_completions # noqa: F401 + return get_transport("chat_completions") + + +class TestProfileHookKeywordCompat: + """``lmstudio_reasoning_options`` is LM Studio-only: a plugin hook that names the older keywords + without ``**context`` must not start raising TypeError on every request.""" + + def test_hook_without_var_kwargs_still_called(self, transport): + from providers.base import ProviderProfile + + class OldSignature(ProviderProfile): + def build_api_kwargs_extras(self, *, reasoning_config=None, supports_reasoning=False, + qwen_session_metadata=None, model=None, base_url=None, + ollama_num_ctx=None, session_id=None, cache_scope_id=None): + return {}, {"reasoning_effort": "low"} + + kw = transport.build_kwargs(model="m", messages=[{"role": "user", "content": "Hi"}], + provider_profile=OldSignature(name="old-signature")) + assert kw["reasoning_effort"] == "low"