c2743251e9
Self-evolving AI scientist framework built on LangGraph/LangChain with CLI/TUI core, FastAPI gateway, and Next.js frontend. Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
44 lines
1.2 KiB
Python
44 lines
1.2 KiB
Python
from __future__ import annotations
|
|
|
|
from unittest.mock import MagicMock
|
|
|
|
from EvoScientist.middleware.utils import disable_thinking
|
|
|
|
|
|
def test_disable_thinking_strips_nested_model_kwargs():
|
|
model = MagicMock()
|
|
model.thinking = None
|
|
model.reasoning = None
|
|
model.model_kwargs = {
|
|
"reasoning": {"effort": "high"},
|
|
"extra_body": {
|
|
"thinking": {"type": "enabled"},
|
|
"enable_thinking": True,
|
|
"keep": "value",
|
|
},
|
|
}
|
|
copied = MagicMock()
|
|
model.model_copy.return_value = copied
|
|
|
|
result = disable_thinking(model)
|
|
|
|
assert result is copied
|
|
update = model.model_copy.call_args.kwargs["update"]
|
|
assert "reasoning" not in update["model_kwargs"]
|
|
assert update["model_kwargs"]["extra_body"] == {"keep": "value"}
|
|
|
|
|
|
def test_disable_thinking_strips_extra_body_field():
|
|
model = MagicMock()
|
|
model.thinking = None
|
|
model.reasoning = None
|
|
model.model_kwargs = {}
|
|
model.extra_body = {"enable_thinking": True, "safe": 1}
|
|
copied = MagicMock()
|
|
model.model_copy.return_value = copied
|
|
|
|
result = disable_thinking(model)
|
|
|
|
assert result is copied
|
|
assert model.model_copy.call_args.kwargs["update"]["extra_body"] == {"safe": 1}
|