refactor(cli): class-level disabled_toolsets default instead of per-site getattr

Inspection surfaces run on partially built HermesCLI instances (tests use
HermesCLI.__new__), so the attribute needs a default; declare it once on
the class next to _seeded_first_message rather than getattr at five sites.
This commit is contained in:
kshitijk4poor
2026-09-05 11:53:17 +05:30
committed by kshitij
parent b1b8ea4f7d
commit 872be057e1
4 changed files with 7 additions and 5 deletions
+2
View File
@@ -2531,6 +2531,8 @@ class HermesCLI(CLIAgentSetupMixin, CLICommandsMixin, CLIBillingMixin, CLITuiMix
# Seeded -q first message (see _should_seed_interactive); run() re-creates # Seeded -q first message (see _should_seed_interactive); run() re-creates
# _pending_input, so it is enqueued only after the fresh queue exists. # _pending_input, so it is enqueued only after the fresh queue exists.
_seeded_first_message: Optional["_SeededQueryMessage"] = None _seeded_first_message: Optional["_SeededQueryMessage"] = None
# Inspection surfaces (banner, /tools, status line) read this on partially built instances too.
disabled_toolsets: Optional[List[str]] = None
def __init__( def __init__(
self, self,
+3 -3
View File
@@ -134,7 +134,7 @@ class CLIInfoMixin:
from model_tools import get_toolset_for_tool from model_tools import get_toolset_for_tool
tools = get_tool_definitions( tools = get_tool_definitions(
enabled_toolsets=self.enabled_toolsets, enabled_toolsets=self.enabled_toolsets,
disabled_toolsets=getattr(self, "disabled_toolsets", None), quiet_mode=True) disabled_toolsets=self.disabled_toolsets, quiet_mode=True)
availability = compute_toolset_availability(self.enabled_toolsets) availability = compute_toolset_availability(self.enabled_toolsets)
tmap = _toolset_map(tools, availability, get_toolset_for_tool) tmap = _toolset_map(tools, availability, get_toolset_for_tool)
save_banner_snapshot(tools, self.enabled_toolsets, availability, tmap) save_banner_snapshot(tools, self.enabled_toolsets, availability, tmap)
@@ -148,7 +148,7 @@ class CLIInfoMixin:
# Cold path: compute live, then persist the snapshot for the next launch. # Cold path: compute live, then persist the snapshot for the next launch.
from model_tools import get_toolset_for_tool from model_tools import get_toolset_for_tool
tools = get_tool_definitions(enabled_toolsets=self.enabled_toolsets, tools = get_tool_definitions(enabled_toolsets=self.enabled_toolsets,
disabled_toolsets=getattr(self, "disabled_toolsets", None), quiet_mode=True) disabled_toolsets=self.disabled_toolsets, quiet_mode=True)
availability = compute_toolset_availability(self.enabled_toolsets) availability = compute_toolset_availability(self.enabled_toolsets)
build_welcome_banner(tools=tools, availability=availability, **banner_kw) build_welcome_banner(tools=tools, availability=availability, **banner_kw)
try: try:
@@ -357,7 +357,7 @@ class CLIInfoMixin:
# Pre-assembly list: /tools is a discovery surface, so it must show the full catalog # Pre-assembly list: /tools is a discovery surface, so it must show the full catalog
# including tools deferred behind the tool_search bridge (users verify MCP installs here). # including tools deferred behind the tool_search bridge (users verify MCP installs here).
tools = get_tool_definitions(enabled_toolsets=self.enabled_toolsets, tools = get_tool_definitions(enabled_toolsets=self.enabled_toolsets,
disabled_toolsets=getattr(self, "disabled_toolsets", None), quiet_mode=True, disabled_toolsets=self.disabled_toolsets, quiet_mode=True,
skip_tool_search_assembly=True) skip_tool_search_assembly=True)
if not tools: if not tools:
print("(;_;) No tools available") print("(;_;) No tools available")
+1 -1
View File
@@ -83,7 +83,7 @@ class CLILoopsMixin:
cc.print(_build_compact_banner()) cc.print(_build_compact_banner())
else: else:
tools = get_tool_definitions(enabled_toolsets=self.enabled_toolsets, tools = get_tool_definitions(enabled_toolsets=self.enabled_toolsets,
disabled_toolsets=getattr(self, "disabled_toolsets", None), quiet_mode=True) disabled_toolsets=self.disabled_toolsets, quiet_mode=True)
agent = getattr(self, "agent", None) agent = getattr(self, "agent", None)
ctx_len = None ctx_len = None
if agent and hasattr(agent, "context_compressor"): if agent and hasattr(agent, "context_compressor"):
+1 -1
View File
@@ -217,7 +217,7 @@ class CLISessionMixin:
tool_status = "tools deferred" tool_status = "tools deferred"
else: else:
tools = get_tool_definitions(enabled_toolsets=self.enabled_toolsets, tools = get_tool_definitions(enabled_toolsets=self.enabled_toolsets,
disabled_toolsets=getattr(self, "disabled_toolsets", None), quiet_mode=True) disabled_toolsets=self.disabled_toolsets, quiet_mode=True)
tool_status = f"{len(tools) if tools else 0} tools" tool_status = f"{len(tools) if tools else 0} tools"
model_short = self.model.split("/")[-1] if "/" in self.model else self.model model_short = self.model.split("/")[-1] if "/" in self.model else self.model