Skip to content

The agent that grows with you

fix(plugins): keep an inherited aux base from being shadowed by write-only empties

Apostol Apostolov5999ecb75d17
diff --git a/agent/auxiliary_client.py b/agent/auxiliary_client.py
index fcc56a6928e..465da0d1a1d 100644
--- a/agent/auxiliary_client.py
+++ b/agent/auxiliary_client.py
@@ -6292,6 +6292,7 @@ def _get_auxiliary_task_config(
# A cycle here means a hand-edited or otherwise malformed registry; fall back to this task's
# own defaults instead of recursing until the stack blows.
cyclic = task in seen
+ # Only when we actually inherit does the user layer need pruning below.
if cyclic:
logger.warning("Auxiliary task %r has a circular inherit_from chain — ignoring inheritance",
task)
@@ -6305,13 +6306,29 @@ def _get_auxiliary_task_config(
if cyclic or not _inherit:
return {**_defaults, **task_config}
base = _get_auxiliary_task_config(_inherit, seen | {task})
- return {**base, **_defaults, **task_config}
+ return {**base, **_defaults, **_explicit_user_config(task_config)}
break
except Exception:
pass # plugin discovery failure must not break aux task config reads
return task_config
+def _explicit_user_config(task_config: Dict[str, Any]) -> Dict[str, Any]:
+ """User config with unset values dropped, so an inherited base is not shadowed by write-only
+ placeholders.
+
+ The aux picker and "reset to auto" persist ``model``, ``base_url``, ``api_key`` and
+ ``reasoning_effort`` as empty strings when the operator expresses no preference for them, and
+ plugin-registered tasks are included in both writers. Merging those empties over the inherited
+ base would discard it for exactly the keys the UI touches, which inverts the whole point of
+ ``inherit_from``.
+
+ Only ``""`` is dropped, never any falsy value: ``provider: "auto"`` is a deliberate choice, and
+ ``reasoning_effort: false`` is an explicit request for no reasoning rather than an unset value.
+ """
+ return {k: v for k, v in task_config.items() if v != ""}
+
+
class CompressionFastLane(NamedTuple):
"""Explicit, non-reasoning compression route."""
diff --git a/hermes_cli/main_provider_setup.py b/hermes_cli/main_provider_setup.py
index 53982c82b4d..8f3706c8ad2 100644
--- a/hermes_cli/main_provider_setup.py
+++ b/hermes_cli/main_provider_setup.py
@@ -132,6 +132,39 @@ def _aux_task_cfg(cfg: dict, task: str) -> dict:
return aux.get(task, {}) if isinstance(aux.get(task), dict) else {}
+def _aux_task_cfg_for_display(cfg: dict, task: str) -> dict:
+ """The routing dict to *display* for *task*, with an inherited base resolved.
+
+ The stored block is authoritative for built-in tasks, but a plugin task registered with
+ ``inherit_from`` may inherit its provider/model from a base task while storing only the fields
+ the operator actually set. Rendering the raw block would then report "auto" while the task
+ actually runs on the base's provider. Falls back to the stored block if the runtime resolver is
+ unavailable, so the menu never depends on importing the agent package.
+ """
+ stored = _aux_task_cfg(cfg, task)
+ if task == _DELEGATION_TASK_KEY:
+ return stored
+ try:
+ from agent.auxiliary_client import _get_auxiliary_task_config
+ except Exception:
+ return stored
+ try:
+ resolved = _get_auxiliary_task_config(task)
+ except Exception:
+ return stored
+ # Only adopt the resolved view when the task really inherits; otherwise keep showing exactly
+ # what is stored, so display behaviour for existing tasks is unchanged.
+ if not resolved:
+ return stored
+ try:
+ from hermes_cli.plugins import get_plugin_auxiliary_tasks
+ inherits = any(e.get("key") == task and e.get("inherit_from")
+ for e in get_plugin_auxiliary_tasks())
+ except Exception:
+ return stored
+ return resolved if inherits else stored
+
+
def _aux_task_display_name(task: str) -> str:
"""Display name for a task key, covering the special delegation entry."""
if task == _DELEGATION_TASK_KEY:
@@ -227,7 +260,7 @@ def _aux_config_menu() -> None:
desc_col = max(len(desc) for _, _, desc in menu_tasks) + 4
entries = [
(task_key, f"{name.ljust(name_col)}{('(' + desc + ')').ljust(desc_col)}"
- f"{_format_aux_current(_aux_task_cfg(cfg, task_key))}")
+ f"{_format_aux_current(_aux_task_cfg_for_display(cfg, task_key))}")
for task_key, name, desc in menu_tasks]
entries.append(("__reset__", "Reset all to auto"))
entries.append(("__back__", "Back"))
@@ -251,7 +284,8 @@ def _aux_select_for_task(task: str) -> None:
``build_aux_picker_rows()`` (shared substrate): only already-configured providers appear."""
from hermes_cli.config import load_config
from hermes_cli.inventory import build_aux_picker_rows, format_aux_picker_entries
- task_cfg = _aux_task_cfg(load_config(), task)
+ cfg = load_config()
+ task_cfg = _aux_task_cfg(cfg, task)
current_provider = str(task_cfg.get("provider") or "auto").strip() or "auto"
current_model = str(task_cfg.get("model") or "").strip()
current_base_url = str(task_cfg.get("base_url") or "").strip()
@@ -274,7 +308,7 @@ def _aux_select_for_task(task: str) -> None:
entries.append(("__custom__", f"Custom endpoint (direct URL){custom_marker}", []))
entries.append(("__back__", "Back", []))
- _say("", f" Configure {display_name} — current: {_format_aux_current(task_cfg)}", "")
+ _say("", f" Configure {display_name} — current: {_format_aux_current(_aux_task_cfg_for_display(cfg, task))}", "")
idx = _prompt_provider_choice([label for _, label, _ in entries], default=0)
if idx is None:
return
diff --git a/tests/hermes_cli/test_plugin_auxiliary_tasks.py b/tests/hermes_cli/test_plugin_auxiliary_tasks.py
index ce659dcf4f2..11d9bb5540e 100644
--- a/tests/hermes_cli/test_plugin_auxiliary_tasks.py
+++ b/tests/hermes_cli/test_plugin_auxiliary_tasks.py
@@ -192,6 +192,94 @@ def test_inheritance_cycle_does_not_recurse(aux_home, patched_manager, caplog):
assert "circular inherit_from" in caplog.text
+# ── inherit_from survives the config writers (empty-string placeholders) ─────
+
+
+def test_inherited_base_survives_picker_written_empty_strings(aux_home, patched_manager):
+ """``_save_aux_choice`` writes model/base_url/api_key as "" for a plugin task; those
+ placeholders must not shadow the inherited base (#review: Enough1122)."""
+ from hermes_cli.config import load_config, save_config
+ from agent.auxiliary_client import _get_auxiliary_task_config
+
+ _register(patched_manager, key="plug_aux", inherit_from="mcp")
+ cfg = load_config()
+ cfg.setdefault("auxiliary", {})["mcp"] = {
+ "provider": "openrouter", "model": "vendor/base-model", "base_url": "https://x"}
+ # Exactly what _save_aux_choice persists after the operator touches the task.
+ cfg["auxiliary"]["plug_aux"] = {"provider": "auto", "model": "", "base_url": "",
+ "api_key": "", "reasoning_effort": ""}
+ save_config(cfg)
+
+ merged = _get_auxiliary_task_config("plug_aux")
+ assert merged["model"] == "vendor/base-model"
+ assert merged["base_url"] == "https://x"
+ assert merged["provider"] == "auto" # an explicit "auto" is a real choice, kept
+
+
+def test_reset_to_auto_empty_strings_do_not_kill_inheritance(aux_home, patched_manager):
+ """After "Reset all to auto" the task still has to run on the base's provider."""
+ from hermes_cli.config import load_config, save_config
+ from agent.auxiliary_client import _get_auxiliary_task_config
+
+ _register(patched_manager, key="plug_aux", inherit_from="mcp")
+ cfg = load_config()
+ cfg.setdefault("auxiliary", {})["mcp"] = {
+ "provider": "openrouter", "model": "vendor/base-model", "base_url": "https://x"}
+ cfg["auxiliary"]["plug_aux"] = {"provider": "auto", "model": "", "base_url": "",
+ "api_key": "", "reasoning_effort": ""}
+ save_config(cfg)
+
+ merged = _get_auxiliary_task_config("plug_aux")
+ assert merged["model"] == "vendor/base-model"
+ assert merged["base_url"] == "https://x"
+
+
+def test_operator_tuned_keys_still_win_over_inherited_base(aux_home, patched_manager):
+ """Pruning "" must not prune real values: a set timeout/model still beats the base."""
+ from hermes_cli.config import load_config, save_config
+ from agent.auxiliary_client import _get_auxiliary_task_config
+
+ _register(patched_manager, key="plug_aux", inherit_from="mcp")
+ cfg = load_config()
+ cfg.setdefault("auxiliary", {})["mcp"] = {"provider": "openrouter", "timeout": 30}
+ cfg["auxiliary"]["plug_aux"] = {"model": "vendor/user", "timeout": 5, "base_url": ""}
+ save_config(cfg)
+
+ merged = _get_auxiliary_task_config("plug_aux")
+ assert merged["model"] == "vendor/user"
+ assert merged["timeout"] == 5
+ assert merged["provider"] == "openrouter" # unset key still inherited
+
+
+def test_reasoning_effort_false_is_kept_not_pruned(aux_home, patched_manager):
+ """``reasoning_effort: false`` means "no reasoning"; it is not an unset placeholder."""
+ from hermes_cli.config import load_config, save_config
+ from agent.auxiliary_client import _get_auxiliary_task_config
+
+ _register(patched_manager, key="plug_aux", inherit_from="mcp")
+ cfg = load_config()
+ cfg.setdefault("auxiliary", {})["mcp"] = {"reasoning_effort": "high"}
+ cfg["auxiliary"]["plug_aux"] = {"reasoning_effort": False}
+ save_config(cfg)
+
+ assert _get_auxiliary_task_config("plug_aux")["reasoning_effort"] is False
+
+
+def test_non_inherited_plugin_task_keeps_placeholder_empties(aux_home, patched_manager):
+ """Pruning is scoped to tasks that actually inherit; other plugins keep today's behaviour."""
+ from hermes_cli.config import load_config, save_config
+ from agent.auxiliary_client import _get_auxiliary_task_config
+
+ _register(patched_manager, key="plug_aux")
+ cfg = load_config()
+ cfg["auxiliary"]["plug_aux"] = {"model": ""}
+ save_config(cfg)
+
+ merged = _get_auxiliary_task_config("plug_aux")
+ assert merged["model"] == "" # key still present with its empty value
+ assert merged["timeout"] == 60
+
+
# ── inherit_from validation ─────────────────────────────────────────────────