Skip to content

The agent that grows with you

fix(agent): display-name title pin for a keyed providers: entry waits too

kshitijk4poora335a1b195aa
diff --git a/agent/title_generator.py b/agent/title_generator.py
index d080cf3e0d4..295a5227f32 100644
--- a/agent/title_generator.py
+++ b/agent/title_generator.py
@@ -196,12 +196,13 @@ def title_upgrade_must_wait_for_turn(main_runtime: Optional[dict]) -> bool:
try:
cfg = _title_config()
pinned_provider = str(cfg.get("provider") or "").strip().lower()
- if pinned_provider not in ("", "auto") and not _title_pin_may_share_endpoint(pinned_provider, provider):
+ main_base_url = str((main_runtime or {}).get("base_url") or "").strip().rstrip("/")
+ if pinned_provider not in ("", "auto") and not _title_pin_may_share_endpoint(
+ pinned_provider, provider, main_base_url):
return False
except Exception:
return True
pinned_base_url = str(cfg.get("base_url") or "").strip().rstrip("/")
- main_base_url = str((main_runtime or {}).get("base_url") or "").strip().rstrip("/")
return not pinned_base_url or pinned_base_url == main_base_url
@@ -215,18 +216,24 @@ def _is_self_hosted_provider(provider: str) -> bool:
return provider in ("custom", "lmstudio", "local") or provider.startswith("custom:")
-def _title_pin_may_share_endpoint(pinned_provider: str, main_provider: str) -> bool:
+def _title_pin_may_share_endpoint(pinned_provider: str, main_provider: str, main_base_url: str) -> bool:
"""A title pin that can land on the turn's own self-hosted server (only its ``base_url`` can prove otherwise).
Hosted pins (``openrouter``…) multiplex and never share the slot. A pin to ``custom``/``lmstudio``/``local``/any
``custom:<name>`` is assumed to share until the caller compares ``base_url``, and a bare ``<name>`` /
display-name pin is the same endpoint when it aliases the main ``custom:<name>`` route
- (``hermes_cli.providers.custom_provider_aliases`` — the resolver's own identity set).
+ (``hermes_cli.providers.custom_provider_aliases`` — the resolver's own identity set) or resolves to a
+ configured custom entry serving ``main_base_url`` (a keyed ``providers:`` entry's display name does not
+ alias its ``custom:<key>`` id).
"""
- from hermes_cli.providers import custom_provider_aliases
+ from hermes_cli.config import get_compatible_custom_providers, load_config_readonly
+ from hermes_cli.providers import custom_provider_aliases, resolve_custom_provider
if _is_self_hosted_provider(pinned_provider):
return True
- return bool(custom_provider_aliases(pinned_provider) & custom_provider_aliases(main_provider))
+ if custom_provider_aliases(pinned_provider) & custom_provider_aliases(main_provider):
+ return True
+ pdef = resolve_custom_provider(pinned_provider, get_compatible_custom_providers(load_config_readonly()))
+ return bool(pdef and main_base_url and pdef.base_url.strip().rstrip("/") == main_base_url)
def start_title_upgrade(upgrade: Optional[threading.Thread]) -> None:
diff --git a/tests/agent/test_title_generator.py b/tests/agent/test_title_generator.py
index a3f4bc187a8..d27ecb307bb 100644
--- a/tests/agent/test_title_generator.py
+++ b/tests/agent/test_title_generator.py
@@ -426,6 +426,7 @@ class TestMaybeAutoTitle:
("custom:gptoss-local", {"provider": "custom:gptoss-local"}, True),
("custom:gptoss-local", {"provider": "gptoss-local"}, True), # bare config name
("custom:gptoss-local", {"provider": "GPTOSS Local"}, True), # display name
+ ("custom:gptoss", {"provider": "GPTOSS Local"}, True), # display name of a keyed `providers:` entry
("custom:gptoss-local", {"provider": "custom"}, True),
("custom:gptoss-local", {"provider": "custom:gptoss-local", "base_url": "http://127.0.0.1:8080/v1/"}, True),
("custom:gptoss-local", {"provider": "custom:other", "base_url": "http://10.0.0.2:8080/v1"}, False),
@@ -446,7 +447,9 @@ class TestMaybeAutoTitle:
from agent import title_generator as tg
main_runtime = {"provider": main_provider, "base_url": "http://127.0.0.1:8080/v1"}
- with patch.object(tg, "_title_config", return_value=title_cfg):
+ keyed = {"providers": {"gptoss": {"name": "GPTOSS Local", "base_url": "http://127.0.0.1:8080/v1"}}}
+ with patch.object(tg, "_title_config", return_value=title_cfg), \
+ patch("hermes_cli.config.load_config_readonly", return_value=keyed):
assert tg.title_upgrade_must_wait_for_turn(main_runtime) is deferred
def test_kanban_worker_is_named_after_its_card_without_the_llm_thread(self, tmp_path, monkeypatch):