fix(skills): respect HERMES_SESSION_PLATFORM in _is_skill_disabled

Fixes #13027

Previously, `_is_skill_disabled()` only checked the explicit `platform`
argument and `os.getenv('HERMES_PLATFORM')`, missing the gateway session
context (`HERMES_SESSION_PLATFORM`). This caused `skill_view()` to expose
skills that were platform-disabled for the active gateway session.

Add `_get_session_platform()` helper that resolves the platform from
`gateway.session_context.get_session_env`, mirroring the logic in
`agent.skill_utils.get_disabled_skill_names()`.

Now the platform resolution follows the same precedence as skill_utils:
1. Explicit `platform` argument
2. `HERMES_PLATFORM` environment variable
3. `HERMES_SESSION_PLATFORM` from gateway session context
This commit is contained in:
zhangguangtao 2026-04-21 20:29:59 +08:00 committed by Teknium
parent 793199ab0b
commit 5c54019055

View file

@ -507,13 +507,33 @@ def _get_disabled_skill_names() -> Set[str]:
return get_disabled_skill_names()
def _get_session_platform() -> str:
"""Resolve the current platform from gateway session context.
Mirrors the platform-resolution logic in
``agent.skill_utils.get_disabled_skill_names`` so that
``_is_skill_disabled`` respects ``HERMES_SESSION_PLATFORM``.
"""
try:
from gateway.session_context import get_session_env
return get_session_env("HERMES_SESSION_PLATFORM") or ""
except Exception:
return ""
def _is_skill_disabled(name: str, platform: str = None) -> bool:
"""Check if a skill is disabled in config."""
"""Check if a skill is disabled in config.
Resolves the active platform from (in order of precedence):
1. Explicit ``platform`` argument
2. ``HERMES_PLATFORM`` environment variable
3. ``HERMES_SESSION_PLATFORM`` from gateway session context
"""
try:
from hermes_cli.config import load_config
config = load_config()
skills_cfg = config.get("skills", {})
resolved_platform = platform or os.getenv("HERMES_PLATFORM")
resolved_platform = platform or os.getenv("HERMES_PLATFORM") or _get_session_platform()
if resolved_platform:
platform_disabled = skills_cfg.get("platform_disabled", {}).get(resolved_platform)
if platform_disabled is not None: