refactor(models): unify preset names

This commit is contained in:
Xubin Ren
2026-08-16 11:50:56 +08:00
parent 8dc08853e4
commit 3dc38f6396
37 changed files with 239 additions and 209 deletions
+20 -2
View File
@@ -33,14 +33,14 @@ def _provider(default_model: str, max_tokens: int = 123) -> MagicMock:
return provider
def _make_loop(tmp_path, *, preset_snapshot_loader=None) -> AgentLoop:
def _make_loop(tmp_path, *, preset_snapshot_loader=None, model_presets=None) -> AgentLoop:
return AgentLoop(
bus=MessageBus(),
provider=_provider("base-model", max_tokens=123),
workspace=tmp_path,
model="base-model",
context_window_tokens=1000,
model_presets={
model_presets=model_presets or {
"default": ModelPresetConfig(
model="base-model",
max_tokens=123,
@@ -106,6 +106,24 @@ async def test_model_command_switches_preset(tmp_path) -> None:
assert status is not None and "openai/gpt-4.1" in status.content
@pytest.mark.asyncio
async def test_model_command_accepts_canonical_names_with_spaces(tmp_path) -> None:
loop = _make_loop(
tmp_path,
model_presets={
"default": ModelPresetConfig(model="base-model"),
"Deep Research": ModelPresetConfig(model="deep-model"),
},
)
out = await cmd_model(
_ctx(loop, "/model deep research", args="deep research"),
)
assert "Switched model preset to `Deep Research`." in out.content
assert _saved_model_preset(loop) == "Deep Research"
@pytest.mark.asyncio
async def test_model_command_switches_back_to_default(tmp_path) -> None:
loop = _make_loop(tmp_path)