The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(agent): match answer_in_reasoning entries against requested_provider too
kshitijk4poorc4895a27a9fe
diff --git a/agent/reasoning_promotion.py b/agent/reasoning_promotion.pyindex 9179f1572c5..309ac62214a 100644--- a/agent/reasoning_promotion.py+++ b/agent/reasoning_promotion.py@@ -49,12 +49,15 @@ def answer_in_reasoning_capability(agent: Any) -> bool:# The provider-level ``capabilities:`` block, re-read on the live route like the per-model key# so it holds on CLI/TUI (no constructor ``capabilities=``) and survives /model switches.# Several entries may share one endpoint (LiteLLM/vLLM router): only the live ``custom:<slug>``- # entry counts; without one, every flagged sibling on the endpoint must opt in.+ # entry counts; without one, every flagged sibling on the endpoint must opt in. Startup, gateway+ # and TUI keep ``provider="custom"`` and the named identity in ``requested_provider``.from hermes_cli.providers import custom_provider_slug+ requested = str(getattr(agent, "requested_provider", "") or "").strip().lower()+ ids = {custom_provider_slug(p) for p in (provider, requested) if p.startswith("custom:")}entries = list(_entries_for_route(base_url, custom_providers, None))live = [e for e in entries- if custom_provider_slug(str(e.get("name") or ""), str(e.get("provider_key") or "")) == provider]+ if custom_provider_slug(str(e.get("name") or ""), str(e.get("provider_key") or "")) in ids]flags = {(e.get("capabilities") or {}).get(_ANSWER_IN_REASONING_CAPABILITY) for e in live or entries}flags &= {True, False}if flags:diff --git a/tests/agent/test_empty_terminal_reasoning_surface.py b/tests/agent/test_empty_terminal_reasoning_surface.pyindex 52532bdf670..6b55aa04436 100644--- a/tests/agent/test_empty_terminal_reasoning_surface.py+++ b/tests/agent/test_empty_terminal_reasoning_surface.py@@ -187,10 +187,10 @@ def test_length_cut_reasoning_is_not_promoted(tmp_path, monkeypatch):("openrouter", "https://openrouter.ai/api/v1", "deepseek/deepseek-v4.1", "the visible answer", 2),("vllm", "http://127.0.0.1:8000/v1", "nvidia/NVIDIA-Nemotron-3.5-Lightning-30B-A3B-NVFP4","private thoughts that must not be shown", 1),- ("custom", "https://llm.example.com/v1", "acme/reasoner", "private thoughts that must not be shown", 1),+ (("custom", "custom:acme"), "https://llm.example.com/v1", "acme/reasoner", "private thoughts that must not be shown", 1),("custom", "https://llm.example.com/v1", "acme/after-model-switch", "private thoughts that must not be shown", 1),("custom", "https://fallback.example.com/v1", "acme/reasoner", "the visible answer", 2),- ("custom:acme-plain", "https://llm.example.com/v1", "acme/reasoner", "the visible answer", 2),+ (("custom", "custom:acme-plain"), "https://llm.example.com/v1", "acme/reasoner", "the visible answer", 2),])def test_reasoning_promotion_requires_a_trusted_route(tmp_path, monkeypatch, provider, base_url, model, final, calls):"""Private reasoning on an untrusted route retries to the visible answer and never@@ -198,7 +198,9 @@ def test_reasoning_promotion_requires_a_trusted_route(tmp_path, monkeypatch, proopt-in promote in one call, re-read on the live route (any model on that provider, never afallback on another base_url), with no constructor ``capabilities=`` (CLI/TUI)."""agent = _build_agent(tmp_path, monkeypatch)- agent.provider, agent.base_url, agent.model = provider, base_url, model+ # A (provider, requested_provider) pair is the startup/gateway shape for a named custom provider.+ agent.provider, agent.requested_provider = provider if isinstance(provider, tuple) else (provider, provider)+ agent.base_url, agent.model = base_url, modelresponses = [_private_reasoning_only_response(),SimpleNamespace(