Skip to content

The agent that grows with you

refactor(aux): delete auxiliary_is_nous and get_auxiliary_extra_body

kshitijk4poor281f3f32e7e3
diff --git a/agent/auxiliary_client.py b/agent/auxiliary_client.py
index 34401444a87..c5fbb661f55 100644
--- a/agent/auxiliary_client.py
+++ b/agent/auxiliary_client.py
@@ -945,19 +945,11 @@ def _ai_gateway_headers() -> dict[str, str]:
return {"HTTP-Referer": "https://hermes-agent.nousresearch.com", "X-Title": "Hermes Agent",
"User-Agent": hermes_user_agent("HermesAgent")}
-# Nous Portal attribution extra_body. Tags come from agent.portal_tags so the client= marker
-# tracks the canonical base version — never inline a literal here.
+# Nous Portal attribution tags, built per call. They come from agent.portal_tags so the client=
+# marker tracks the canonical base version — never inline a literal here.
from agent.portal_tags import nous_portal_tags as _nous_portal_tags
-def _nous_extra_body() -> dict:
- """Fresh Nous Portal ``extra_body`` (per call, so a hot-reloaded version is reflected)."""
- return {"tags": _nous_portal_tags()}
-
-
-# Set at resolve time — True if the auxiliary client points to Nous Portal
-auxiliary_is_nous: bool = False
-
# _OPENROUTER_MODEL MUST stay a :free SKU (matching the free_only warning): this lane engages
# silently, and a paid default meant spend the user never opted into. User-configured values
# are honored untouched (_warn_paid_lane_once fires).
@@ -2403,12 +2395,9 @@ def _try_nous(vision: bool = False) -> tuple[Optional[OpenAI], Optional[str]]:
# Vision rides the same id (the backing model is multimodal; a backing that is not answers
# the request with the upstream's own error, which the ladder handles like any other).
from hermes_cli.anon_auth import GUEST_MODEL, route_is_welcome_host
- global auxiliary_is_nous
if route_is_welcome_host(base_url):
- auxiliary_is_nous = True
logger.debug("Auxiliary/%s: Nous free tier; using %s", lane, GUEST_MODEL)
return _create_openai_client(api_key=api_key, base_url=base_url), GUEST_MODEL
- auxiliary_is_nous = True
logger.debug("Auxiliary client: Nous Portal")
# Portal recommended-models is authoritative (tier-aware); _NOUS_MODEL when unreachable/null.
# Probes skip the lookup: exact model is irrelevant and it hits the network.
@@ -4631,8 +4620,6 @@ def _resolve_auto_route(
per-task overrides still win); (2) configured fallback policy — task chain, then the main agent's
top-level chain; (3) OpenRouter → Nous → custom → Codex → API-key providers, only with no policy
and no working main client."""
- global auxiliary_is_nous
- auxiliary_is_nous = False # Reset — _try_nous() will set True if it wins
runtime = _normalize_main_runtime(main_runtime)
_warn_stale_openai_base_url(runtime.get("provider", ""))
main_provider, main_model, base_url, api_key, api_mode = _main_route_target(runtime, task)
@@ -5677,11 +5664,6 @@ def resolve_vision_provider_client(
return requested, client, (final_model if client is not None else None)
-def get_auxiliary_extra_body() -> dict:
- """Return extra_body kwargs (Nous Portal product tags when Nous-backed, else {})."""
- return _nous_extra_body() if auxiliary_is_nous else {}
-
-
def auxiliary_max_tokens_param(value: int, *, model: Optional[str] = None) -> dict:
"""Max-tokens kwarg for the auxiliary provider: direct OpenAI, a custom endpoint whose profile declares
it, and newer OpenAI-family models (by ``model`` name: custom endpoints fronting gpt-5.x) need max_completion_tokens."""
diff --git a/tests/agent/test_auxiliary_client.py b/tests/agent/test_auxiliary_client.py
index 5fdb5ec8548..d8ded60d535 100644
--- a/tests/agent/test_auxiliary_client.py
+++ b/tests/agent/test_auxiliary_client.py
@@ -443,11 +443,9 @@ class TestBuildCallKwargsMaxTokens:
class TestNousTagsScoping:
- def test_tags_injected_when_provider_is_nous(self, monkeypatch):
+ def test_tags_injected_when_provider_is_nous(self):
import agent.auxiliary_client as aux
- monkeypatch.setattr(aux, "auxiliary_is_nous", False)
-
kwargs = aux._build_call_kwargs(
provider="nous",
model="hermes-4",
@@ -456,16 +454,18 @@ class TestNousTagsScoping:
assert kwargs["extra_body"]["tags"] == aux._nous_portal_tags()
- def test_tags_not_injected_for_gemini_when_main_is_nous(self, monkeypatch):
+ def test_tags_not_injected_for_non_nous_provider_when_main_is_nous(self):
import agent.auxiliary_client as aux
- monkeypatch.setattr(aux, "auxiliary_is_nous", True)
-
- kwargs = aux._build_call_kwargs(
- provider="gemini",
- model="gemini-2.5-flash",
- messages=[{"role": "user", "content": "hi"}],
- )
+ with aux.scoped_runtime_main({
+ "provider": "nous", "model": "Hermes-4",
+ "base_url": "https://inference-api.nousresearch.com/v1", "api_key": "nous-key",
+ }):
+ kwargs = aux._build_call_kwargs(
+ provider="gemini",
+ model="gemini-2.5-flash",
+ messages=[{"role": "user", "content": "hi"}],
+ )
assert "extra_body" not in kwargs
diff --git a/tests/agent/test_nous_welcome_client_contract.py b/tests/agent/test_nous_welcome_client_contract.py
index f9e146fff8a..55d0b947fc8 100644
--- a/tests/agent/test_nous_welcome_client_contract.py
+++ b/tests/agent/test_nous_welcome_client_contract.py
@@ -34,7 +34,6 @@ class TestAuxiliaryOnWelcomeHost:
assert (client, model) == ("client", anon_auth.GUEST_MODEL)
assert create.call_args.kwargs["base_url"] == WELCOME
recommended.assert_not_called() # the Portal's pick would be a guaranteed 429 model_not_free
- assert ac.auxiliary_is_nous is True
def test_vision_aux_on_welcome_host_uses_the_same_model(self):
import agent.auxiliary_client as ac
diff --git a/tests/hermes_cli/test_kanban_decompose.py b/tests/hermes_cli/test_kanban_decompose.py
index b56e9f1f44a..19d12dd54d1 100644
--- a/tests/hermes_cli/test_kanban_decompose.py
+++ b/tests/hermes_cli/test_kanban_decompose.py
@@ -51,12 +51,6 @@ def _patch_aux_client(content: str, *, model: str = "test-model"):
)
-def _patch_extra_body():
- # No-op shim retained for call-site compatibility: extra_body plumbing
- # now lives inside call_llm, which _patch_aux_client already mocks.
- return patch("agent.auxiliary_client.get_auxiliary_extra_body", return_value={})
-
-
def _patch_list_profiles(names: list[str]):
"""Pretend the named profiles exist. The decomposer uses
profiles_mod.list_profiles() to build the roster + valid-set, and
@@ -93,7 +87,7 @@ def test_decompose_with_fanout_creates_children(kanban_home):
for p in patches:
p.start()
try:
- with _patch_aux_client(llm_payload), _patch_extra_body():
+ with _patch_aux_client(llm_payload):
outcome = decomp.decompose_task(tid, author="me")
finally:
for p in patches:
@@ -137,7 +131,7 @@ def test_decompose_fanout_children_inherit_root_assignee_when_unrouted(kanban_ho
for p in patches:
p.start()
try:
- with _patch_aux_client(llm_payload), _patch_extra_body(), patch(
+ with _patch_aux_client(llm_payload), patch(
"hermes_cli.config.load_config_readonly",
return_value={},
):
@@ -179,7 +173,7 @@ def test_decompose_explicit_default_assignee_wins_over_root_assignee(kanban_home
for p in patches:
p.start()
try:
- with _patch_aux_client(llm_payload), _patch_extra_body(), patch(
+ with _patch_aux_client(llm_payload), patch(
"hermes_cli.config.load_config_readonly",
return_value={"kanban": {"default_assignee": "docs"}},
):
@@ -212,7 +206,7 @@ def test_decompose_fanout_false_invalid_llm_assignee_uses_default(kanban_home):
for p in patches:
p.start()
try:
- with _patch_aux_client(llm_payload), _patch_extra_body(), patch(
+ with _patch_aux_client(llm_payload), patch(
"hermes_cli.config.load_config_readonly",
return_value={"kanban": {"default_assignee": "fallback"}},
):
diff --git a/tests/hermes_cli/test_profile_describer.py b/tests/hermes_cli/test_profile_describer.py
index 1bd91fdd4b3..e4f85241762 100644
--- a/tests/hermes_cli/test_profile_describer.py
+++ b/tests/hermes_cli/test_profile_describer.py
@@ -64,9 +64,7 @@ def test_describer_writes_description_with_auto_true(profile_env, monkeypatch):
)
payload = jsonlib.dumps({"description": "writes Python codebases"})
- with _patch_aux_client(payload), patch(
- "agent.auxiliary_client.get_auxiliary_extra_body", return_value={}
- ):
+ with _patch_aux_client(payload):
outcome = describer.describe_profile("myprof")
assert outcome.ok, outcome.reason
@@ -95,7 +93,7 @@ def test_describer_refuses_json_shaped_reply_that_does_not_parse(registered_prof
it must be refused and leave profile.yaml untouched -- including behind an uppercase fence."""
profiles_mod.write_profile_meta(registered_profile, description="previous", description_auto=True)
before = (registered_profile / "profile.yaml").read_bytes()
- with _patch_aux_client(raw), patch("agent.auxiliary_client.get_auxiliary_extra_body", return_value={}):
+ with _patch_aux_client(raw):
outcome = describer.describe_profile("myprof", overwrite=True)
assert outcome.ok is False
assert (registered_profile / "profile.yaml").read_bytes() == before
@@ -103,8 +101,7 @@ def test_describer_refuses_json_shaped_reply_that_does_not_parse(registered_prof
def test_describer_still_accepts_plain_prose_fallback(registered_profile):
"""A reply that never looked like JSON keeps the lenient one-paragraph prose fallback."""
- with _patch_aux_client("Writes and debugs Python codebases.\n\nSecond paragraph is dropped."), \
- patch("agent.auxiliary_client.get_auxiliary_extra_body", return_value={}):
+ with _patch_aux_client("Writes and debugs Python codebases.\n\nSecond paragraph is dropped."):
outcome = describer.describe_profile("myprof")
assert outcome.ok, outcome.reason
assert outcome.description == "Writes and debugs Python codebases."