Skip to content

The agent that grows with you

fix(doctor): flag a non-list custom_providers and legacy list entries with no providers: twin; name the edited profile on Custom Endpoints / Local Models

teknium13e182f46c3ed
diff --git a/apps/desktop/src/app/settings/custom-endpoints-settings.tsx b/apps/desktop/src/app/settings/custom-endpoints-settings.tsx
index 6213dc73e8d..4c48e57953d 100644
--- a/apps/desktop/src/app/settings/custom-endpoints-settings.tsx
+++ b/apps/desktop/src/app/settings/custom-endpoints-settings.tsx
@@ -19,6 +19,7 @@ import { notify, notifyError } from '@/store/notifications'
import type { CustomEndpoint, CustomEndpointUpdate } from '@/types/hermes'
import { EmptyState, Pill, SectionHeading, SettingsContent, SettingsSkeleton } from './primitives'
+import { ActiveProfileNote } from './profile-scope'
interface CustomEndpointsSettingsProps {
onConfigSaved?: () => void
@@ -231,6 +232,7 @@ export function CustomEndpointsSettings({ onConfigSaved, onMainModelChanged }: C
return (
<SettingsContent>
+ <ActiveProfileNote className="mb-5" />
<div className="space-y-6">
<section>
<SectionHeading icon={Globe} meta={`${endpoints.length}`} title={t.settings.customEndpoints.title} />
diff --git a/apps/desktop/src/app/settings/local-models-settings.tsx b/apps/desktop/src/app/settings/local-models-settings.tsx
index e271c55f5dd..b5ac9ffa005 100644
--- a/apps/desktop/src/app/settings/local-models-settings.tsx
+++ b/apps/desktop/src/app/settings/local-models-settings.tsx
@@ -51,6 +51,7 @@ import { notify, notifyError } from '@/store/notifications'
import type { LocalCatalogModel, LocalHardware, LocalModelsStatus } from '@/types/hermes'
import { ListRow, Pill, SettingsContent, SettingsSection, SettingsSkeleton } from './primitives'
+import { ActiveProfileNote } from './profile-scope'
function ProgressBar({ percent }: { percent: number | undefined }) {
return (
@@ -405,6 +406,7 @@ export function LocalModelsSettings() {
return (
<SettingsContent>
+ <ActiveProfileNote className="mb-5" />
{/* ── Runtime ── */}
<SettingsSection
aside={
diff --git a/apps/desktop/src/app/settings/profile-scope.test.tsx b/apps/desktop/src/app/settings/profile-scope.test.tsx
index 556c9cfa94e..327a97e8989 100644
--- a/apps/desktop/src/app/settings/profile-scope.test.tsx
+++ b/apps/desktop/src/app/settings/profile-scope.test.tsx
@@ -22,7 +22,7 @@ vi.mock('@/store/starmap', () => ({ resetStarmapGraph: vi.fn() }))
const { $activeGatewayProfile, $profiles } = await import('@/store/profile')
const { $settingsScopeOverride } = await import('@/store/settings-scope')
-const { SettingsProfileScope } = await import('./profile-scope')
+const { ActiveProfileNote, SettingsProfileScope } = await import('./profile-scope')
const profile = (name: string, isDefault = false, extra: Partial<ProfileInfo> = {}): ProfileInfo =>
({ has_env: false, is_default: isDefault, model: null, name, ...extra }) as ProfileInfo
@@ -138,3 +138,20 @@ describe('SettingsProfileScope', () => {
expect(document.querySelector('[role="status"]')?.textContent).not.toContain('coder')
})
})
+
+// Custom Endpoints / Local Models send unscoped requests, so they always edit
+// the ACTIVE profile; the note must say which one — and stay silent for
+// single-profile users, like the selector.
+describe('ActiveProfileNote', () => {
+ it('names the active profile (by its chip label) only with two or more profiles', () => {
+ $activeGatewayProfile.set('setup')
+ $profiles.set([profile('default', true)])
+ const { container, rerender } = render(<ActiveProfileNote />)
+ expect(container.textContent).toBe('')
+
+ $profiles.set([profile('default', true), profile('setup', false, { display_name: 'Setup box' })])
+ rerender(<ActiveProfileNote />)
+ expect(screen.getByRole('status').textContent).toContain('Setup box')
+ expect($settingsScopeOverride.get()).toBeNull()
+ })
+})
diff --git a/apps/desktop/src/app/settings/profile-scope.tsx b/apps/desktop/src/app/settings/profile-scope.tsx
index 4641db23fe3..19a9d32968d 100644
--- a/apps/desktop/src/app/settings/profile-scope.tsx
+++ b/apps/desktop/src/app/settings/profile-scope.tsx
@@ -3,7 +3,7 @@ import { useEffect } from 'react'
import { useI18n } from '@/i18n'
import { cn } from '@/lib/utils'
-import { $profiles, normalizeProfileKey, profileLabel, refreshProfiles } from '@/store/profile'
+import { $activeGatewayProfile, $profiles, normalizeProfileKey, profileLabel, refreshProfiles } from '@/store/profile'
import {
$settingsScopeEditsNonDefault,
$settingsScopeOverride,
@@ -107,3 +107,32 @@ export function SettingsProfileScope({ className }: { className?: string }) {
</div>
)
}
+
+/** Read-only note for Providers pages whose requests carry no scope and so
+ * always edit the app's ACTIVE profile (Custom Endpoints, Local Models) — the
+ * reporter's "which profile am I editing?" gap. Same string as the selector's
+ * note above; hidden with fewer than two profiles like the selector itself. */
+export function ActiveProfileNote({ className }: { className?: string }) {
+ const { t } = useI18n()
+ const active = useStore($activeGatewayProfile)
+ const profiles = useStore($profiles)
+
+ if (profiles.length < 2) {
+ return null
+ }
+
+ const key = normalizeProfileKey(active)
+ const profile = profiles.find(candidate => normalizeProfileKey(candidate.name) === key)
+
+ return (
+ <p
+ className={cn(
+ 'text-[length:var(--conversation-caption-font-size)] leading-(--conversation-caption-line-height) text-(--ui-text-tertiary)',
+ className
+ )}
+ role="status"
+ >
+ {t.settings.profileScope.editsProfile(profile ? settingsScopeLabel(profile) : key)}
+ </p>
+ )
+}
diff --git a/hermes_cli/config.py b/hermes_cli/config.py
index 99c9a3e8cdc..3b8533061bd 100644
--- a/hermes_cli/config.py
+++ b/hermes_cli/config.py
@@ -1217,13 +1217,14 @@ def _validate_entry_list(
_require_fields(issues, entry, f"{label}[{i}]", fields)
+_CP_LIST_HINT = "Change to:\n custom_providers:\n - name: my-provider\n base_url: https://...\n api_key: ..."
+
+
def _validate_custom_providers(cp: Any, issues: List[ConfigIssue]) -> None:
- """custom_providers must be a list of dicts, not a dict."""
+ """custom_providers must be a list of dicts — a dict or a scalar is silently dropped by the runtime."""
if isinstance(cp, dict):
_issue(issues, "error",
- "custom_providers is a dict — it must be a YAML list (items prefixed with '-')",
- "Change to:\n custom_providers:\n - name: my-provider\n base_url: https://...\n"
- " api_key: ...")
+ "custom_providers is a dict — it must be a YAML list (items prefixed with '-')", _CP_LIST_HINT)
suspicious = set(cp.keys()) & _CUSTOM_PROVIDER_LIKE_FIELDS
if suspicious:
_issue(issues, "warning",
@@ -1233,6 +1234,12 @@ def _validate_custom_providers(cp: Any, issues: List[ConfigIssue]) -> None:
_validate_entry_list(cp, "custom_providers", issues, _CP_REQUIRED_FIELDS, non_dict=(
"warning", "custom_providers[{i}] is not a dict (got {type})",
"Each entry should have at minimum: name, base_url"))
+ else:
+ # get_compatible_custom_providers() returns [] for any non-list: every endpoint vanishes
+ # ("0 endpoints") with nothing naming the cause.
+ _issue(issues, "error",
+ f"custom_providers is a {type(cp).__name__} — it must be a YAML list (items prefixed with '-'); "
+ "every custom endpoint is ignored until it is", _CP_LIST_HINT)
def _validate_fallback_model(fb: Any, issues: List[ConfigIssue]) -> None:
diff --git a/hermes_cli/doctor_config.py b/hermes_cli/doctor_config.py
index 9ee3b4604a3..f7bdba4ffed 100644
--- a/hermes_cli/doctor_config.py
+++ b/hermes_cli/doctor_config.py
@@ -387,8 +387,40 @@ def _drift_structure(f: Finding, should_fix: bool, config_path) -> None:
f.issues.append(ci.message)
+def _endpoint_url(entry: dict) -> str:
+ """Comparable endpoint URL of a legacy list entry (``base_url``/``url``) or a ``providers:`` entry (``api``)."""
+ url = entry.get("api") or entry.get("base_url") or entry.get("url") or ""
+ return str(url).strip().rstrip("/").lower()
+
+
+def _drift_legacy_custom_providers(f: Finding, should_fix: bool, config_path) -> None:
+ """Legacy ``custom_providers`` list entries with no ``providers:`` twin (raw-file diagnostic).
+
+ The v11→v12 migration (config_migrations._migrate_to_12) moves the list into ``providers:`` ONCE, at
+ the version bump; an entry hand-written afterwards is served by the chat picker (dual-read) but has no
+ row on the Custom Endpoints settings pages, which list only ``providers:`` — deletable nowhere.
+ """
+ from hermes_cli.config import read_user_config_raw
+ raw_config = read_user_config_raw(config_path)
+ legacy = raw_config.get("custom_providers")
+ if not isinstance(legacy, list):
+ return
+ providers = raw_config.get("providers")
+ twins = {_endpoint_url(e) for e in (providers.values() if isinstance(providers, dict) else ()) if isinstance(e, dict)}
+ for entry in legacy:
+ if not isinstance(entry, dict) or not _endpoint_url(entry) or _endpoint_url(entry) in twins:
+ continue
+ label = str(entry.get("name") or "").strip() or _endpoint_url(entry)
+ check_warn(f"Legacy custom_providers entry '{label}' has no providers: twin",
+ "(shown in the model picker, missing from the Custom Endpoints settings page)")
+ f.manual_issues.append(
+ f"Move custom_providers entry '{label}' into config.yaml providers: as `providers.<key>.api: "
+ f"{_endpoint_url(entry)}` and delete it from the list — the v12 list migration ran once and does not re-fire")
+
+
_CONFIG_DRIFT_STEPS = (
_drift_config_version, _drift_stale_root_keys, _drift_max_iterations_ghost, _drift_deprecations, _drift_structure,
+ _drift_legacy_custom_providers,
)
diff --git a/tests/hermes_cli/test_config_validation.py b/tests/hermes_cli/test_config_validation.py
index 5e52986d020..9e6081566fa 100644
--- a/tests/hermes_cli/test_config_validation.py
+++ b/tests/hermes_cli/test_config_validation.py
@@ -36,6 +36,15 @@ class TestCustomProvidersValidation:
"Should detect custom_providers as dict instead of list"
)
+ def test_scalar_is_an_error_naming_key_and_type(self):
+ """A non-list scalar (a bad `config set`) makes every endpoint vanish — name the key and the type."""
+ issues = validate_config_structure({"custom_providers": "oops", "model": {"provider": "openrouter"}})
+ errors = [i.message for i in issues if i.severity == "error"]
+ assert any(m.startswith("custom_providers is a str") and "list" in m for m in errors), errors
+ assert not [i for i in validate_config_structure(
+ {"custom_providers": [{"name": "x", "base_url": "http://h/v1"}], "model": {"provider": "custom"}})
+ if i.severity == "error"]
+
def test_dict_detects_misplaced_fields(self):
"""When custom_providers is a dict, detect fields that look misplaced."""
issues = validate_config_structure({
diff --git a/tests/hermes_cli/test_doctor.py b/tests/hermes_cli/test_doctor.py
index eceddebdf5a..09748f91d25 100644
--- a/tests/hermes_cli/test_doctor.py
+++ b/tests/hermes_cli/test_doctor.py
@@ -1534,6 +1534,36 @@ class TestDoctorStaleMaxIterationsDrift:
assert "shadows" not in out
+class TestDoctorLegacyCustomProvidersResidue:
+ """A legacy ``custom_providers`` list entry without a ``providers:`` twin is picker-visible but has no
+ Custom Endpoints row; doctor must name it and point at the move. Twins (URL modulo trailing slash /
+ case) and non-list values are not this step's business."""
+
+ def _run(self, tmp_path, yaml_text):
+ cfg = tmp_path / "config.yaml"
+ cfg.write_text(yaml_text, encoding="utf-8")
+ finding = doctor_config.Finding()
+ buf = io.StringIO()
+ with contextlib.redirect_stdout(buf):
+ doctor_config._drift_legacy_custom_providers(finding, False, cfg)
+ return buf.getvalue(), finding
+
+ def test_orphan_entry_is_flagged_with_repair_instruction(self, tmp_path):
+ out, finding = self._run(tmp_path, (
+ "custom_providers:\n - name: Local (8283)\n base_url: http://127.0.0.1:8283/v1\n"
+ "providers:\n other:\n api: http://127.0.0.1:8290/v1\n"))
+ assert "Legacy custom_providers entry 'Local (8283)' has no providers: twin" in out
+ assert finding.manual_issues and "providers.<key>.api: http://127.0.0.1:8283/v1" in finding.manual_issues[0]
+ assert finding.fixed == 0 and finding.issues == [] # warn-only: no --fix rewrite of config.yaml
+
+ def test_twin_and_scalar_are_silent(self, tmp_path):
+ out, finding = self._run(tmp_path, (
+ "custom_providers:\n - name: Local\n base_url: http://127.0.0.1:8283/V1/\n"
+ "providers:\n local:\n api: http://127.0.0.1:8283/v1\n"))
+ assert out == "" and finding.manual_issues == []
+ out, finding = self._run(tmp_path, "custom_providers: oops\n")
+ assert out == "" and finding.manual_issues == []
+
class TestDoctorDeprecatedConfigAndEnv:
diff --git a/website/docs/reference/cli-commands.md b/website/docs/reference/cli-commands.md
index fa3b79df91b..4804f9a1bee 100644
--- a/website/docs/reference/cli-commands.md
+++ b/website/docs/reference/cli-commands.md
@@ -911,6 +911,11 @@ hermes doctor [--fix]
The **API Connectivity** section includes an `IPv6 route` check: it opens one short (2 s) IPv6 TCP connection to a known dual-stack host. A route that is advertised but only times out (a blackholed IPv6 prefix) is reported as a warning naming the remedy, `network.force_ipv4: true`. Having no IPv6 route at all is healthy and reported as OK; the check is skipped when `force_ipv4` is already set.
+Custom-endpoint config checks (both warn-only; `--fix` does not rewrite them):
+
+- `custom_providers` that is not a YAML list (for example a string left by a bad `config set`) is reported as an error naming the key and the received type — the runtime ignores every custom endpoint until it is a list again.
+- A legacy `custom_providers` list entry with no matching `providers:` entry (same endpoint URL) is reported with the move to make: such an entry shows up in the model picker but has no row on the Custom Endpoints settings page, and the one-shot v12 migration that moved the list into `providers:` does not run again.
+
## `hermes dump`
```bash