Skip to content

DeepTutor: Lifelong Personalized Tutoring. https://deeptutor.info/.

fix(doctor): convert resolved LLM config before the online probe

0xtidalbore6af53e2582c0
diff --git a/deeptutor/services/doctor.py b/deeptutor/services/doctor.py
index bbae73326..c51c900d0 100644
--- a/deeptutor/services/doctor.py
+++ b/deeptutor/services/doctor.py
@@ -376,8 +376,13 @@ async def run_diagnostics(
"""Run setup diagnostics without network access unless ``online`` is set."""
if resolve_llm is None:
from deeptutor.services.config import resolve_llm_runtime_config
+ from deeptutor.services.model_selection.runtime import llm_config_from_resolved
+
+ # The probe hands this config to ``complete_with_config``, which needs
+ # an LLMConfig, not the provider-runtime ResolvedLLMConfig.
+ def resolve_llm() -> Any:
+ return llm_config_from_resolved(resolve_llm_runtime_config())
- resolve_llm = resolve_llm_runtime_config
if data_root is None:
from deeptutor.services.path_service import get_path_service
diff --git a/tests/cli/test_doctor_cli.py b/tests/cli/test_doctor_cli.py
index fbcfcd883..c045e5d15 100644
--- a/tests/cli/test_doctor_cli.py
+++ b/tests/cli/test_doctor_cli.py
@@ -570,3 +570,39 @@ def test_doctor_online_rich_output_succeeds(monkeypatch) -> None:
assert result.exit_code == 0, result.output
assert "PASS" in result.output
assert "Provider response" in result.output
+
+
+async def test_online_probe_converts_default_resolved_config(monkeypatch, tmp_path) -> None:
+ """The default resolver yields ResolvedLLMConfig; the probe needs an LLMConfig."""
+ from deeptutor.services.config.provider_runtime import ResolvedLLMConfig
+ from deeptutor.services.llm.config import LLMConfig
+
+ resolved = ResolvedLLMConfig(
+ model="gpt-4o-mini",
+ provider_name="openai",
+ provider_mode="standard",
+ api_key="sk-test-secret",
+ base_url="https://api.openai.com/v1",
+ effective_url="https://api.openai.com/v1",
+ )
+ captured = {}
+
+ async def fake_complete(config, **kwargs):
+ captured["config"] = config
+ captured["api_key"] = config.get_api_key()
+ return "OK"
+
+ monkeypatch.setattr("deeptutor.services.config.resolve_llm_runtime_config", lambda: resolved)
+ monkeypatch.setattr("deeptutor.services.llm.factory.complete_with_config", fake_complete)
+
+ report = await run_diagnostics(
+ online=True,
+ data_root=tmp_path,
+ load_rag_config=lambda: {"defaults": {}, "knowledge_bases": {}},
+ )
+
+ assert report.ok is True
+ assert isinstance(captured["config"], LLMConfig)
+ assert captured["config"].model == "gpt-4o-mini"
+ assert captured["api_key"] == "sk-test-secret"