From cf5d112534b4cc609c328c61437fc94839468266 Mon Sep 17 00:00:00 2001 From: FriedorixNietzsche <177403988+FriedorixNietzsche@users.noreply.github.com> Date: Fri, 25 Sep 2026 13:21:51 +0800 Subject: [PATCH 1/2] fix: recognize referenced task model in readiness --- deeptutor/services/config/readiness.py | 24 ++++++++++++++ tests/services/config/test_readiness.py | 43 +++++++++++++++++++++++++ 2 files changed, 67 insertions(+) diff --git a/deeptutor/services/config/readiness.py b/deeptutor/services/config/readiness.py index 0127bca6f..8340604fa 100644 --- a/deeptutor/services/config/readiness.py +++ b/deeptutor/services/config/readiness.py @@ -237,6 +237,30 @@ def catalog_service_rows( required = name in required_services 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. + 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 + active_profile_id = service.get("active_profile_id") if not active_profile_id: rows.append( diff --git a/tests/services/config/test_readiness.py b/tests/services/config/test_readiness.py index b97b49d86..34cb9d901 100644 --- a/tests/services/config/test_readiness.py +++ b/tests/services/config/test_readiness.py @@ -58,6 +58,49 @@ def test_catalog_readiness_is_value_free_and_detects_stale_selection() -> None: assert "secret-model-name" not in serialized +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", + }, + } + ) + + rows = catalog_service_rows(catalog) + + task = next(row for row in rows if row["id"] == "catalog.task") + assert task["state"] == "enabled_verified" + assert task["detail_code"] == "configuration_verified" + assert task["configured"] is True + assert task["verified"] is True + + dependency_rows = {row["id"]: row for row in rows} + reason = next( + row for row in tool_rows(["reason"], dependency_rows) if row["id"] == "tool.reason" + ) + assert reason["state"] == "enabled_verified" + assert reason["detail_code"] == "tool_ready" + + def test_selected_remote_parser_must_be_installed_ready_and_reachable() -> None: entries = [ {"id": "tika", "name": "Tika", "available": True}, From d11ea96d9989ac81f1d697415314aeb6cbe73d4b Mon Sep 17 00:00:00 2001 From: "Bingxi Zhao (Frank)" <13051345080@163.com> Date: Sun, 27 Sep 2026 02:25:33 +0800 Subject: [PATCH 2/2] fix: validate task model references in readiness --- deeptutor/services/config/readiness.py | 33 ++++------- tests/services/config/test_readiness.py | 79 +++++++++++++++++-------- 2 files changed, 66 insertions(+), 46 deletions(-) diff --git a/deeptutor/services/config/readiness.py b/deeptutor/services/config/readiness.py index 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.py index 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},