Build and run agents you can see, understand and trust.
Python agentchatbotlarge-language-modelsllmllm-agentmcpmulti-agentmulti-modalreact-agentrealtime-agentvoice-agentvoice-assistant
feat(model): support tri-state thinking controls across adapters and UI (#3557)
qbc9ce66c350953
diff --git a/examples/web_ui/frontend/src/components/popover/ModelParametersPopover.tsx b/examples/web_ui/frontend/src/components/popover/ModelParametersPopover.tsxindex d226b7624..030ddca9a 100644--- a/examples/web_ui/frontend/src/components/popover/ModelParametersPopover.tsx+++ b/examples/web_ui/frontend/src/components/popover/ModelParametersPopover.tsx@@ -48,6 +48,8 @@ interface ParameterProperty {exclusiveMaximum?: number;enum?: unknown[];anyOf?: ParameterProperty[];+ /** Reset these parameters on edit only when their controls are hidden. */+ 'x-reset-hidden-on-change'?: Record<string, unknown>;}interface ParameterSchema {@@ -105,16 +107,57 @@ interface FieldProps {}function BooleanField({ id, label, prop, value, onChange }: FieldProps) {+ const { t } = useTranslation();+ const nullable = prop.anyOf?.some((variant) => variant.type === 'null');+ const current = value !== undefined ? value : prop.default;+ const selected = current === true ? 'true' : current === false ? 'false' : 'default';+ const options = [+ { value: 'default', label: t('model-parameters.booleanDefault') },+ { value: 'true', label: t('model-parameters.booleanEnabled') },+ { value: 'false', label: t('model-parameters.booleanDisabled') },+ ];+return (<><Label htmlFor={id} className="min-w-0 whitespace-normal leading-tight">{label}</Label>- <Switch- id={id}- checked={value !== undefined ? !!value : !!prop.default}- onCheckedChange={(checked) => onChange(!!checked)}- />+ {nullable ? (+ <DropdownMenu>+ <DropdownMenuTrigger asChild>+ <Button+ id={id}+ variant="outline"+ className="min-w-0 w-full justify-between gap-1"+ >+ <span className="truncate">+ {options.find((option) => option.value === selected)?.label}+ </span>+ <ChevronDown className="size-3.5 opacity-50 shrink-0" />+ </Button>+ </DropdownMenuTrigger>+ <DropdownMenuContent align="start" onPointerDown={(e) => e.stopPropagation()}>+ <DropdownMenuRadioGroup+ value={selected}+ onValueChange={(next) =>+ onChange(next === 'default' ? null : next === 'true')+ }+ >+ {options.map((option) => (+ <DropdownMenuRadioItem key={option.value} value={option.value}>+ {option.label}+ </DropdownMenuRadioItem>+ ))}+ </DropdownMenuRadioGroup>+ </DropdownMenuContent>+ </DropdownMenu>+ ) : (+ <Switch+ id={id}+ checked={!!current}+ onCheckedChange={(checked) => onChange(!!checked)}+ />+ )}</>);}@@ -309,10 +352,17 @@ export function ModelParametersPopover({if (value === '' || value === undefined) {delete next[key];}+ const properties = schema?.properties ?? {};+ const resets = properties[key]?.['x-reset-hidden-on-change'] ?? {};+ for (const [target, resetValue] of Object.entries(resets)) {+ if (!Object.hasOwn(properties, target)) {+ next[target] = resetValue;+ }+ }setValues(next);onChange(next);},- [values, onChange],+ [values, onChange, schema],);const handleSelectFallback = (diff --git a/examples/web_ui/frontend/src/i18n/locales/en.json b/examples/web_ui/frontend/src/i18n/locales/en.jsonindex 810e1acb4..165800f4e 100644--- a/examples/web_ui/frontend/src/i18n/locales/en.json+++ b/examples/web_ui/frontend/src/i18n/locales/en.json@@ -558,6 +558,9 @@},"model-parameters": {"title": "Model Parameters",+ "booleanDefault": "Default",+ "booleanEnabled": "On",+ "booleanDisabled": "Off","description": "Adjust inference parameters for the selected model.","empty": "No configurable parameters.","fallbackLabel": "Fallback model",diff --git a/examples/web_ui/frontend/src/i18n/locales/zh.json b/examples/web_ui/frontend/src/i18n/locales/zh.jsonindex 22c482414..4e675fa0a 100644--- a/examples/web_ui/frontend/src/i18n/locales/zh.json+++ b/examples/web_ui/frontend/src/i18n/locales/zh.json@@ -558,6 +558,9 @@},"model-parameters": {"title": "模型参数",+ "booleanDefault": "默认",+ "booleanEnabled": "开启",+ "booleanDisabled": "关闭","description": "调整所选模型的推理参数。","empty": "暂无可配置参数。","fallbackLabel": "兜底模型",diff --git a/src/agentscope/middleware/_longterm_memory/_reme/_config.py b/src/agentscope/middleware/_longterm_memory/_reme/_config.pyindex 44900c366..988e6d63f 100644--- a/src/agentscope/middleware/_longterm_memory/_reme/_config.py+++ b/src/agentscope/middleware/_longterm_memory/_reme/_config.py@@ -290,7 +290,9 @@ def _memory_components(},"parameters": {"max_tokens": 65_536,- "thinking_enable": False,+ # Preserve the pre-tristate fallback behavior: omit+ # thinking controls and use the provider default.+ "thinking_enable": None,},},},diff --git a/src/agentscope/model/_anthropic/_model.py b/src/agentscope/model/_anthropic/_model.pyindex 2bf8f2b83..f1b584a87 100644--- a/src/agentscope/model/_anthropic/_model.py+++ b/src/agentscope/model/_anthropic/_model.py@@ -43,10 +43,15 @@ class AnthropicChatModel(ChatModelBase):gt=0,)- thinking_enable: bool = Field(- default=False,+ thinking_enable: bool | None = Field(+ default=None,title="Thinking",- description="The thinking enable for the LLM output.",+ description=(+ "Whether to enable budget-based thinking. False sends "+ "thinking.type='disabled'. When None, this toggle does not "+ "add a thinking configuration. An explicit thinking_mode "+ "takes precedence."+ ),)thinking_budget: int | None = Field(@@ -178,10 +183,12 @@ class AnthropicChatModel(ChatModelBase):"""Resolve the effective thinking mode.``thinking_mode`` is the modern control; ``thinking_enable`` is the- legacy toggle that only ever meant the budget-based mode.+ legacy toggle that enables budget-based thinking or disables it."""if self.parameters.thinking_mode is not None:return self.parameters.thinking_mode+ if self.parameters.thinking_enable is False:+ return "disabled"return "enabled" if self.parameters.thinking_enable else Nonedef _build_thinking_config(diff --git a/src/agentscope/model/_minimax/_model.py b/src/agentscope/model/_minimax/_model.pyindex 8d8ff29e7..306a9c977 100644--- a/src/agentscope/model/_minimax/_model.py+++ b/src/agentscope/model/_minimax/_model.py@@ -29,10 +29,15 @@ class MiniMaxChatModel(AnthropicChatModel):gt=0,)- thinking_enable: bool = Field(- default=False,+ thinking_enable: bool | None = Field(+ default=None,title="Thinking",- description="Whether to enable adaptive thinking.",+ description=(+ "None omits the thinking configuration and uses the "+ "provider default. True sends thinking.type='adaptive'. "+ "False sends thinking.type='disabled'; whether disabling "+ "thinking is supported depends on the model."+ ),)def __init__(@@ -86,7 +91,13 @@ class MiniMaxChatModel(AnthropicChatModel):self,max_tokens: int,) -> tuple[dict[str, Any] | None, int]:- """MiniMax only accepts adaptive thinking, without a token budget."""+ """Send adaptive or disabled thinking, without a token budget.++ MiniMax-M3 accepts disabled; M3.1-Flash rejects it. See:+ https://platform.minimax.io/docs/api-reference/text-anthropic-api+ """+ if self.parameters.thinking_enable is False:+ return {"type": "disabled"}, max_tokensif self.parameters.thinking_enable:return {"type": "adaptive"}, max_tokensreturn None, max_tokensdiff --git a/src/agentscope/model/_openai_chat/_model.py b/src/agentscope/model/_openai_chat/_model.pyindex a14c4183e..f6d12b330 100644--- a/src/agentscope/model/_openai_chat/_model.py+++ b/src/agentscope/model/_openai_chat/_model.py@@ -48,13 +48,15 @@ class OpenAIChatModel(ChatModelBase):gt=0,)- thinking_enable: bool = Field(- default=False,+ thinking_enable: bool | None = Field(+ default=None,title="Thinking",description=(- "Whether to enable reasoning for reasoning models "- "(e.g. o3, o4-mini, gpt-5.5). Use reasoning_effort to "- "control the depth of reasoning."+ "None and True forward reasoning_effort when it is set, "+ "including 'none'. If reasoning_effort is unset, neither "+ "adds reasoning parameters; the provider default applies. "+ "False overrides reasoning_effort with 'none' to request "+ "that reasoning be disabled."),)@@ -69,6 +71,9 @@ class OpenAIChatModel(ChatModelBase):"model-dependent and may include: none, minimal, low, ""medium, high, xhigh."),+ json_schema_extra={+ "x-reset-hidden-on-change": {"thinking_enable": None},+ },)temperature: float | None = Field(@@ -240,10 +245,9 @@ class OpenAIChatModel(ChatModelBase):if self.parameters.top_p is not None:kwargs["top_p"] = self.parameters.top_p- if (- self.parameters.thinking_enable- and self.parameters.reasoning_effort- ):+ if self.parameters.thinking_enable is False:+ kwargs["reasoning_effort"] = "none"+ elif self.parameters.reasoning_effort is not None:kwargs["reasoning_effort"] = self.parameters.reasoning_effortif self.parameters.voice is not None:diff --git a/src/agentscope/model/_openai_chat/_models/gpt-6-luna.yaml b/src/agentscope/model/_openai_chat/_models/gpt-6-luna.yamlindex 3da3ca1f3..a762c230d 100644--- a/src/agentscope/model/_openai_chat/_models/gpt-6-luna.yaml+++ b/src/agentscope/model/_openai_chat/_models/gpt-6-luna.yaml@@ -19,10 +19,6 @@ context_size: 1050000output_size: 128000parameter_overrides:- # The adapter gates effort on thinking_enable, which is auto-hidden.- # Keep the provider's default reasoning until that gate is updated.- reasoning_effort:- hidden: truetemperature:hidden: truetop_p:diff --git a/src/agentscope/model/_openai_chat/_models/gpt-6-sol.yaml b/src/agentscope/model/_openai_chat/_models/gpt-6-sol.yamlindex cbb517ebe..81afeb229 100644--- a/src/agentscope/model/_openai_chat/_models/gpt-6-sol.yaml+++ b/src/agentscope/model/_openai_chat/_models/gpt-6-sol.yaml@@ -19,10 +19,6 @@ context_size: 1050000output_size: 128000parameter_overrides:- # The adapter gates effort on thinking_enable, which is auto-hidden.- # Keep the provider's default reasoning until that gate is updated.- reasoning_effort:- hidden: truetemperature:hidden: truetop_p:diff --git a/src/agentscope/model/_openai_chat/_models/gpt-6.1-sol.yaml b/src/agentscope/model/_openai_chat/_models/gpt-6.1-sol.yamlindex 5d23f4628..e1d5736e2 100644--- a/src/agentscope/model/_openai_chat/_models/gpt-6.1-sol.yaml+++ b/src/agentscope/model/_openai_chat/_models/gpt-6.1-sol.yaml@@ -19,10 +19,6 @@ context_size: 1050000output_size: 128000parameter_overrides:- # The adapter gates effort on thinking_enable, which is auto-hidden.- # Keep the provider's default reasoning until that gate is updated.- reasoning_effort:- hidden: truetemperature:hidden: truetop_p:diff --git a/src/agentscope/model/_openai_response/_model.py b/src/agentscope/model/_openai_response/_model.pyindex ebc092388..78f493315 100644--- a/src/agentscope/model/_openai_response/_model.py+++ b/src/agentscope/model/_openai_response/_model.py@@ -69,13 +69,15 @@ class OpenAIResponseModel(ChatModelBase):gt=0,)- thinking_enable: bool = Field(- default=False,+ thinking_enable: bool | None = Field(+ default=None,title="Thinking",description=(- "Whether to enable reasoning for reasoning models "- "(e.g. o3, o4-mini, gpt-5.5). Use reasoning_effort to "- "control the depth of reasoning."+ "None and True forward reasoning_effort as reasoning.effort "+ "when it is set, including 'none'. If reasoning_effort is "+ "unset, neither adds reasoning parameters; the provider "+ "default applies. False overrides reasoning.effort with "+ "'none' to request that reasoning be disabled."),)@@ -90,6 +92,9 @@ class OpenAIResponseModel(ChatModelBase):"model-dependent and may include: none, minimal, low, ""medium, high, xhigh."),+ json_schema_extra={+ "x-reset-hidden-on-change": {"thinking_enable": None},+ },)temperature: float | None = Field(@@ -218,10 +223,9 @@ class OpenAIResponseModel(ChatModelBase):if self.parameters.temperature is not None:api_kwargs["temperature"] = self.parameters.temperature- if (- self.parameters.thinking_enable- and self.parameters.reasoning_effort- ):+ if self.parameters.thinking_enable is False:+ api_kwargs["reasoning"] = {"effort": "none"}+ elif self.parameters.reasoning_effort is not None:api_kwargs["reasoning"] = {"effort": self.parameters.reasoning_effort,}diff --git a/src/agentscope/model/_openai_response/_models/gpt-6-luna.yaml b/src/agentscope/model/_openai_response/_models/gpt-6-luna.yamlindex a7f99c091..6d726e010 100644--- a/src/agentscope/model/_openai_response/_models/gpt-6-luna.yaml+++ b/src/agentscope/model/_openai_response/_models/gpt-6-luna.yaml@@ -18,9 +18,5 @@ context_size: 1050000output_size: 128000parameter_overrides:- # The adapter gates effort on thinking_enable, which is auto-hidden.- # Keep the provider's default reasoning until that gate is updated.- reasoning_effort:- hidden: truetemperature:hidden: truediff --git a/src/agentscope/model/_openai_response/_models/gpt-6-sol.yaml b/src/agentscope/model/_openai_response/_models/gpt-6-sol.yamlindex 698809574..70dbc2a4b 100644--- a/src/agentscope/model/_openai_response/_models/gpt-6-sol.yaml+++ b/src/agentscope/model/_openai_response/_models/gpt-6-sol.yaml@@ -18,9 +18,5 @@ context_size: 1050000output_size: 128000parameter_overrides:- # The adapter gates effort on thinking_enable, which is auto-hidden.- # Keep the provider's default reasoning until that gate is updated.- reasoning_effort:- hidden: truetemperature:hidden: truediff --git a/src/agentscope/model/_openai_response/_models/gpt-6.1-sol.yaml b/src/agentscope/model/_openai_response/_models/gpt-6.1-sol.yamlindex 61d576724..a21d9d3e8 100644--- a/src/agentscope/model/_openai_response/_models/gpt-6.1-sol.yaml+++ b/src/agentscope/model/_openai_response/_models/gpt-6.1-sol.yaml@@ -18,9 +18,5 @@ context_size: 1050000output_size: 128000parameter_overrides:- # The adapter gates effort on thinking_enable, which is auto-hidden.- # Keep the provider's default reasoning until that gate is updated.- reasoning_effort:- hidden: truetemperature:hidden: truediff --git a/src/agentscope/model/_xai/_model.py b/src/agentscope/model/_xai/_model.pyindex 98ecbeb1c..c0987ae1f 100644--- a/src/agentscope/model/_xai/_model.py+++ b/src/agentscope/model/_xai/_model.py@@ -47,13 +47,15 @@ class XAIChatModel(ChatModelBase):)"""The maximum number of tokens to generate."""- thinking_enable: bool = Field(- default=False,+ thinking_enable: bool | None = Field(+ default=None,title="Thinking",description=(- "Whether to enable reasoning for models that support "- "extended thinking (e.g. ``grok-3-mini``). Use "- "reasoning_effort to control the depth of reasoning."+ "None and True forward reasoning_effort when it is set. "+ "If reasoning_effort is unset, neither adds reasoning "+ "parameters; the provider default applies. False raises "+ "ValueError before making a request because this adapter "+ "does not support disabling thinking."),)@@ -64,8 +66,8 @@ class XAIChatModel(ChatModelBase):"Controls the depth of reasoning for models that support ""extended thinking (e.g. ``grok-3-mini``). Set to ""``'low'``, ``'medium'``, or ``'high'`` to enable reasoning "- "with the corresponding effort level. ``None`` disables "- "reasoning."+ "with the corresponding effort level. When None, no "+ "reasoning effort is sent."),)@@ -185,6 +187,13 @@ class XAIChatModel(ChatModelBase):generator of ``ChatResponse`` objects when streaming isenabled."""+ if self.parameters.thinking_enable is False:+ raise ValueError(+ "The xAI SDK does not support disabling thinking. "+ "Set thinking_enable to None or True and use "+ "reasoning_effort to control reasoning depth.",+ )+from xai_sdk import AsyncClientclient = AsyncClient(@@ -206,10 +215,7 @@ class XAIChatModel(ChatModelBase):create_kwargs["temperature"] = self.parameters.temperatureif self.parameters.top_p is not None:create_kwargs["top_p"] = self.parameters.top_p- if (- self.parameters.thinking_enable- and self.parameters.reasoning_effort- ):+ if self.parameters.reasoning_effort is not None:create_kwargs["reasoning_effort"] = self.parameters.reasoning_effortdiff --git a/tests/model_anthropic_test.py b/tests/model_anthropic_test.pyindex 504baa6d0..cb9f74644 100644--- a/tests/model_anthropic_test.py+++ b/tests/model_anthropic_test.py@@ -423,6 +423,43 @@ class TestAnthropicThinkingMode(IsolatedAsyncioTestCase):def _thinking(self) -> Any:return self.mock_create.call_args.kwargs.get("thinking")+ async def test_thinking_enable_nullable(self) -> None:+ """False disables thinking unless an explicit mode takes priority."""+ self.assertIsNone(AnthropicChatModel.Parameters().thinking_enable)+ for params in (+ {},+ {"thinking_enable": None},+ {"thinking_enable": False},+ {"thinking_enable": True},+ ):+ for mode in (None, "adaptive", "disabled"):+ with self.subTest(params=params, mode=mode):+ self.model.parameters = AnthropicChatModel.Parameters(+ **params,+ thinking_mode=mode,+ )+ await self.model([])++ expected = {+ "model": "claude-opus-4-5",+ "messages": [],+ "stream": False,+ "max_tokens": 8192,+ }+ if mode is not None:+ expected["thinking"] = {"type": mode}+ elif params.get("thinking_enable") is False:+ expected["thinking"] = {"type": "disabled"}+ elif params.get("thinking_enable"):+ expected["thinking"] = {+ "type": "enabled",+ "budget_tokens": 4096,+ }+ self.assertEqual(+ self.mock_create.call_args.kwargs,+ expected,+ )+async def test_no_thinking_by_default(self) -> None:"""Neither control set means no thinking config is sent."""await self.model([])@@ -459,6 +496,25 @@ class TestAnthropicThinkingMode(IsolatedAsyncioTestCase):self.assertEqual(self._thinking(), {"type": "disabled"})+ async def test_false_drops_budget_and_display(self) -> None:+ """Disabled thinking omits budget/display without expanding tokens."""+ self.model.parameters.thinking_enable = False+ self.model.parameters.thinking_budget = 16_384+ self.model.parameters.thinking_display = "summarized"++ await self.model([])++ self.assertEqual(+ self.mock_create.call_args.kwargs,+ {+ "model": "claude-opus-4-5",+ "messages": [],+ "stream": False,+ "max_tokens": 8192,+ "thinking": {"type": "disabled"},+ },+ )+async def test_legacy_toggle_still_means_budget_mode(self) -> None:"""thinking_enable keeps its old meaning when mode is unset."""self.model.parameters.thinking_enable = Truediff --git a/tests/model_minimax_test.py b/tests/model_minimax_test.pyindex e4389385e..aea647e9d 100644--- a/tests/model_minimax_test.py+++ b/tests/model_minimax_test.py@@ -18,6 +18,42 @@ from agentscope.model import MiniMaxChatModelclass MiniMaxTest(IsolatedAsyncioTestCase):"""Tests for the MiniMax-specific behavior."""+ async def test_thinking_enable_nullable(self) -> None:+ """Null omits thinking, while booleans send explicit modes."""+ self.assertIsNone(MiniMaxChatModel.Parameters().thinking_enable)+ model = MiniMaxChatModel(+ credential=MiniMaxCredential(api_key="test"),+ model="MiniMax-M3",+ stream=False,+ )+ response = MagicMock(id="msg-1", content=[])+ response.usage = MagicMock(input_tokens=1, output_tokens=1)+ model.client = MagicMock()+ mock_create = AsyncMock(return_value=response)+ model.client.messages.create = mock_create++ for params in (+ {},+ {"thinking_enable": None},+ {"thinking_enable": False},+ {"thinking_enable": True},+ ):+ with self.subTest(params=params):+ model.parameters = MiniMaxChatModel.Parameters(**params)+ await model([])++ expected = {+ "model": "MiniMax-M3",+ "messages": [],+ "stream": False,+ "max_tokens": 8192,+ }+ if params.get("thinking_enable") is False:+ expected["thinking"] = {"type": "disabled"}+ elif params.get("thinking_enable"):+ expected["thinking"] = {"type": "adaptive"}+ self.assertEqual(mock_create.call_args.kwargs, expected)+async def test_request_kwargs(self) -> None:"""Thinking is sent as adaptive without budget or output config."""model = MiniMaxChatModel(diff --git a/tests/model_openai_chat_test.py b/tests/model_openai_chat_test.pyindex 2a4804b37..9aeb8453d 100644--- a/tests/model_openai_chat_test.py+++ b/tests/model_openai_chat_test.py@@ -174,6 +174,36 @@ class TestOpenAIChatNonStream(IsolatedAsyncioTestCase):self.mock_client = MagicMock()self.model.client = self.mock_client+ async def test_thinking_enable_nullable(self) -> None:+ """False requests no reasoning, even with a stored effort value."""+ self.assertIsNone(OpenAIChatModel.Parameters().thinking_enable)+ mock_create = AsyncMock(return_value=_mock_completion(text="Hi"))+ self.mock_client.chat.completions.create = mock_create++ for params, disables_thinking in (+ ({}, False),+ ({"thinking_enable": None}, False),+ ({"thinking_enable": False}, True),+ ({"thinking_enable": True}, False),+ ):+ for effort in (None, "none", "high"):+ with self.subTest(params=params, effort=effort):+ self.model.parameters = OpenAIChatModel.Parameters(+ **params,+ reasoning_effort=effort,+ )+ await self.model([])++ expected = {+ "model": "gpt-4o",+ "messages": [],+ "stream": False,+ }+ expected_effort = "none" if disables_thinking else effort+ if expected_effort is not None:+ expected["reasoning_effort"] = expected_effort+ self.assertEqual(mock_create.call_args.kwargs, expected)+async def test_text_response(self) -> None:"""Non-stream text response returns a single ChatResponse."""mock_create = AsyncMock(diff --git a/tests/model_openai_response_test.py b/tests/model_openai_response_test.pyindex edae07538..8358e72ff 100644--- a/tests/model_openai_response_test.py+++ b/tests/model_openai_response_test.py@@ -203,6 +203,36 @@ class TestOpenAIResponseNonStream(IsolatedAsyncioTestCase):self.mock_client = MagicMock()self.model.client = self.mock_client+ async def test_thinking_enable_nullable(self) -> None:+ """False requests no reasoning, even with a stored effort value."""+ self.assertIsNone(OpenAIResponseModel.Parameters().thinking_enable)+ mock_create = AsyncMock(return_value=_mock_completion(text="Hi"))+ self.mock_client.responses.create = mock_create++ for params, disables_thinking in (+ ({}, False),+ ({"thinking_enable": None}, False),+ ({"thinking_enable": False}, True),+ ({"thinking_enable": True}, False),+ ):+ for effort in (None, "none", "high"):+ with self.subTest(params=params, effort=effort):+ self.model.parameters = OpenAIResponseModel.Parameters(+ **params,+ reasoning_effort=effort,+ )+ await self.model([])++ expected = {+ "model": "o4-mini",+ "input": [],+ "stream": False,+ }+ expected_effort = "none" if disables_thinking else effort+ if expected_effort is not None:+ expected["reasoning"] = {"effort": expected_effort}+ self.assertEqual(mock_create.call_args.kwargs, expected)+async def test_text_response(self) -> None:"""Non-stream text response returns a single ChatResponse."""mock_create = AsyncMock(diff --git a/tests/model_xai_test.py b/tests/model_xai_test.pyindex a3e47d6b5..a3d46b01f 100644--- a/tests/model_xai_test.py+++ b/tests/model_xai_test.py@@ -213,6 +213,58 @@ class TestXAINonStream(IsolatedAsyncioTestCase):def setUp(self) -> None:self.model = _make_model(stream=False)+ @patch("xai_sdk.AsyncClient")+ async def test_thinking_enable_nullable(+ self,+ mock_client_cls: MagicMock,+ ) -> None:+ """Null and true toggles allow an explicit reasoning effort."""+ self.assertIsNone(XAIChatModel.Parameters().thinking_enable)+ mock_create = mock_client_cls.return_value.chat.create+ mock_create.return_value = _MockChatStream(+ sample_response=_mock_completion(text="Hi"),+ )+ mock_client_cls.return_value.close = AsyncMock()++ for params in (+ {},+ {"thinking_enable": None},+ {"thinking_enable": True},+ ):+ for effort in (None, "high"):+ with self.subTest(params=params, effort=effort):+ self.model.parameters = XAIChatModel.Parameters(+ **params,+ reasoning_effort=effort,+ )+ await self.model([])++ expected = {"model": "grok-3"}+ if effort is not None:+ expected["reasoning_effort"] = "high"+ self.assertEqual(mock_create.call_args.kwargs, expected)++ @patch("xai_sdk.AsyncClient")+ async def test_thinking_disable_rejected(+ self,+ mock_client_cls: MagicMock,+ ) -> None:+ """Reject disabling thinking before creating an SDK client."""+ for stream in (False, True):+ for effort in (None, "high"):+ with self.subTest(stream=stream, effort=effort):+ self.model.stream = stream+ self.model.parameters = XAIChatModel.Parameters(+ thinking_enable=False,+ reasoning_effort=effort,+ )+ with self.assertRaisesRegex(+ ValueError,+ "xAI SDK does not support disabling thinking",+ ):+ await self.model([])+ mock_client_cls.assert_not_called()+@patch("xai_sdk.AsyncClient")async def test_text_response(self, mock_client_cls: MagicMock) -> None:"""Non-stream text response returns a single ChatResponse."""diff --git a/tests/reme_middleware_test.py b/tests/reme_middleware_test.pyindex 7ff7b2c82..69d97fff1 100644--- a/tests/reme_middleware_test.py+++ b/tests/reme_middleware_test.py@@ -21,6 +21,7 @@ from typing import Anyfrom utils import MockModelfrom agentscope.agent import Agent+from agentscope.credential import OpenAICredentialfrom agentscope.event import (ExternalExecutionResultEvent,UserConfirmResultEvent,@@ -34,6 +35,9 @@ from agentscope.message import ()from agentscope.embedding import EmbeddingModelBasefrom agentscope.middleware import ReMeMiddleware+from agentscope.middleware._longterm_memory._reme._config import (+ _build_reme_app_config,+)from agentscope.middleware._longterm_memory._reme._utils import (_extract_memory_texts,_extract_query_text,@@ -525,6 +529,10 @@ class TestConstructorValidation(IsolatedAsyncioTestCase):["daily_dir", "digest_dir"],)components = captured["components"]+ self.assertEqual(+ components["as_llm"]["default"]["parameters"],+ {"max_tokens": 65_536, "thinking_enable": None},+ )self.assertEqual(set(components["file_catalog"]), {"dream"})self.assertNotIn("as_embedding", components)self.assertNotIn("embedding_store", components)@@ -533,6 +541,55 @@ class TestConstructorValidation(IsolatedAsyncioTestCase):"",)+ async def test_default_llm_omits_thinking_request_parameters(self) -> None:+ """The environment-backed OpenAI path leaves thinking unspecified."""+ with mock.patch.dict(+ "os.environ",+ {+ "LLM_API_KEY": "test",+ "LLM_BASE_URL": "https://example.test/compatible-mode/v1",+ },+ clear=True,+ ):+ config = _build_reme_app_config(workspace_dir="memory")++ llm_config = config["components"]["as_llm"]["default"]+ self.assertEqual(llm_config["backend"], "openai")+ credential = OpenAICredential(**llm_config["credential"])+ model_cls = credential.get_chat_model_class()+ parameters = model_cls.Parameters(**llm_config["parameters"])+ stream = mock.MagicMock()+ stream.__aenter__.return_value = stream+ stream.__aiter__.return_value = []+ mock_create = mock.AsyncMock(return_value=stream)++ with mock.patch("openai.AsyncClient") as mock_client_cls:+ mock_client_cls.return_value.chat.completions.create = mock_create+ model = model_cls(+ credential=credential,+ model=llm_config["model"],+ parameters=parameters,+ stream=llm_config["stream"],+ context_size=llm_config["context_size"],+ max_retries=llm_config["max_retries"],+ )+ response = await model([])+ assert not isinstance(response, ChatResponse)+ async for _ in response:+ pass++ self.assertEqual(+ mock_create.call_args.kwargs,+ {+ "model": "qwen3.7-plus",+ "messages": [],+ "stream": True,+ "max_completion_tokens": 65_536,+ "stream_options": {"include_usage": True},+ },+ )+ mock_create.assert_awaited_once()+def test_embedding_model_enables_internal_vector_store(self) -> None:"""An embedding model extends the minimal config with vector search."""captured: dict = {}