fix: hide Honcho session line on CLI load when no API key configured (#1582)

HonchoClientConfig.from_env() set enabled=True unconditionally,
even when HONCHO_API_KEY was not set. When ~/.honcho/config.json
didn't exist, from_global_config() fell back to from_env() and
returned enabled=True with a null api_key, causing the Honcho
session indicator to display on every CLI launch.

Fix: from_env() now sets enabled=bool(api_key), matching the
auto-enable logic already used in from_global_config().
Also added api_key guard to the CLI display as defense-in-depth.
This commit is contained in:
Teknium
2026-03-16 17:22:52 -07:00
committed by GitHub
parent 2158c44efd
commit 181077b785
2 changed files with 4 additions and 3 deletions

View File

@@ -114,11 +114,12 @@ class HonchoClientConfig:
@classmethod
def from_env(cls, workspace_id: str = "hermes") -> HonchoClientConfig:
"""Create config from environment variables (fallback)."""
api_key = os.environ.get("HONCHO_API_KEY")
return cls(
workspace_id=workspace_id,
api_key=os.environ.get("HONCHO_API_KEY"),
api_key=api_key,
environment=os.environ.get("HONCHO_ENVIRONMENT", "production"),
enabled=True,
enabled=bool(api_key),
)
@classmethod