DeepTutor: Lifelong Personalized Tutoring. https://deeptutor.info/.
Python ai-agentsai-tutorclawbotcli-tooldeepresearchinteractive-learninglearningmulti-agent-systemsrag
fix: validate task model references in readiness
Bingxi Zhao (Frank)d11ea96d9989
diff --git a/deeptutor/services/config/readiness.py b/deeptutor/services/config/readiness.pyindex 8340604fa..c648a49b6 100644--- a/deeptutor/services/config/readiness.py+++ b/deeptutor/services/config/readiness.py@@ -238,28 +238,19 @@ def catalog_service_rows(service = services.get(name) if isinstance(services.get(name), dict) else {}profiles = service.get("profiles") if isinstance(service.get("profiles"), list) else []- # Task models may reference a configured chat model instead of owning- # a task-specific profile. Reuse the task runtime's canonical check so- # readiness agrees with the configuration that will actually run.+ # A task reference selects a chat profile/model. Classify the selected+ # model below with the same checks as every other catalog service.if name == "task" and service.get("mode") == "reference":- from deeptutor.services.model_selection.tasks import task_service_configured-- if task_service_configured(catalog):- rows.append(- readiness_row(- "catalog.task",- "catalog",- _SERVICE_LABELS[name],- "enabled_verified",- "configuration_verified",- enabled=True,- available=True,- configured=True,- verified=True,- required=required,- )- )- continue+ selection = service.get("selection")+ selection = selection if isinstance(selection, dict) else {}+ chat_service = services.get("llm") if isinstance(services.get("llm"), dict) else {}+ service = {+ **service,+ "active_profile_id": selection.get("profile_id"),+ "active_model_id": selection.get("model_id"),+ "profiles": chat_service.get("profiles"),+ }+ profiles = service["profiles"] if isinstance(service["profiles"], list) else []active_profile_id = service.get("active_profile_id")if not active_profile_id:diff --git a/tests/services/config/test_readiness.py b/tests/services/config/test_readiness.pyindex 34cb9d901..b06583ec3 100644--- a/tests/services/config/test_readiness.py+++ b/tests/services/config/test_readiness.py@@ -32,6 +32,27 @@ def _empty_catalog() -> dict:}+def _task_reference_catalog() -> dict:+ catalog = _empty_catalog()+ catalog["services"]["llm"] = {+ "active_profile_id": "llm-profile",+ "active_model_id": "llm-model",+ "profiles": [+ {+ "id": "llm-profile",+ "models": [{"id": "llm-model", "model": "test-model"}],+ }+ ],+ }+ catalog["services"]["task"].update(+ {+ "mode": "reference",+ "selection": {"profile_id": "llm-profile", "model_id": "llm-model"},+ }+ )+ return catalog++def test_catalog_readiness_is_value_free_and_detects_stale_selection() -> None:catalog = _empty_catalog()catalog["services"]["llm"] = {@@ -59,31 +80,7 @@ def test_catalog_readiness_is_value_free_and_detects_stale_selection() -> None:def test_task_reference_mode_is_ready_and_enables_reason_tool() -> None:- catalog = _empty_catalog()- catalog["services"]["llm"] = {- "active_profile_id": "llm-profile",- "active_model_id": "llm-model",- "profiles": [- {- "id": "llm-profile",- "models": [- {- "id": "llm-model",- "model": "test-model",- }- ],- }- ],- }- catalog["services"]["task"].update(- {- "mode": "reference",- "selection": {- "profile_id": "llm-profile",- "model_id": "llm-model",- },- }- )+ catalog = _task_reference_catalog()rows = catalog_service_rows(catalog)@@ -101,6 +98,38 @@ def test_task_reference_mode_is_ready_and_enables_reason_tool() -> None:assert reason["detail_code"] == "tool_ready"+def test_task_reference_rejects_empty_model_and_stale_selection() -> None:+ catalog = _task_reference_catalog()+ catalog["services"]["llm"]["profiles"][0]["models"][0]["model"] = ""+ task = next(row for row in catalog_service_rows(catalog) if row["id"] == "catalog.task")+ assert task["state"] == "misconfigured"+ assert task["detail_code"] == "model_identifier_missing"++ catalog["services"]["task"]["selection"]["model_id"] = "removed-model"+ task = next(row for row in catalog_service_rows(catalog) if row["id"] == "catalog.task")+ assert task["state"] == "misconfigured"+ assert task["detail_code"] == "active_model_missing"+++def test_task_reference_rejects_stale_provider_link() -> None:+ catalog = _task_reference_catalog()+ catalog["services"]["llm"]["profiles"][0]["provider_ref"] = {+ "connection_id": "removed-connection"+ }++ rows = catalog_service_rows(catalog)++ task = next(row for row in rows if row["id"] == "catalog.task")+ assert task["state"] == "misconfigured"+ assert task["detail_code"] == "required_credential_missing"+ reason = next(+ row+ for row in tool_rows(["reason"], {row["id"]: row for row in rows})+ if row["id"] == "tool.reason"+ )+ assert reason["state"] != "enabled_verified"++def test_selected_remote_parser_must_be_installed_ready_and_reachable() -> None:entries = [{"id": "tika", "name": "Tika", "available": True},