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:
@@ -2531,6 +2531,8 @@ class HermesCLI(CLIAgentSetupMixin, CLICommandsMixin, CLIBillingMixin, CLITuiMix
|
||||
# Seeded -q first message (see _should_seed_interactive); run() re-creates
|
||||
# _pending_input, so it is enqueued only after the fresh queue exists.
|
||||
_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__(
|
||||
self,
|
||||
|
||||
@@ -134,7 +134,7 @@ class CLIInfoMixin:
|
||||
from model_tools import get_toolset_for_tool
|
||||
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)
|
||||
tmap = _toolset_map(tools, availability, get_toolset_for_tool)
|
||||
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.
|
||||
from model_tools import get_toolset_for_tool
|
||||
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)
|
||||
build_welcome_banner(tools=tools, availability=availability, **banner_kw)
|
||||
try:
|
||||
@@ -357,7 +357,7 @@ class CLIInfoMixin:
|
||||
# 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).
|
||||
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)
|
||||
if not tools:
|
||||
print("(;_;) No tools available")
|
||||
|
||||
@@ -83,7 +83,7 @@ class CLILoopsMixin:
|
||||
cc.print(_build_compact_banner())
|
||||
else:
|
||||
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)
|
||||
ctx_len = None
|
||||
if agent and hasattr(agent, "context_compressor"):
|
||||
|
||||
@@ -217,7 +217,7 @@ class CLISessionMixin:
|
||||
tool_status = "tools deferred"
|
||||
else:
|
||||
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"
|
||||
|
||||
model_short = self.model.split("/")[-1] if "/" in self.model else self.model
|
||||
|
||||
Reference in New Issue
Block a user