Skip to content

test(skills): cover additional rescan paths in skill_commands cache (#14536)#19042

Closed
Tranquil-Flow wants to merge 1 commit into
NousResearch:mainfrom
Tranquil-Flow:coverage/14536-skill-commands-rescan-paths
Closed

test(skills): cover additional rescan paths in skill_commands cache (#14536)#19042
Tranquil-Flow wants to merge 1 commit into
NousResearch:mainfrom
Tranquil-Flow:coverage/14536-skill-commands-rescan-paths

Conversation

@Tranquil-Flow

Copy link
Copy Markdown
Contributor

Summary

Adds three regression tests on top of the rescan-on-platform-change fix
that landed in #18739, covering code paths in
_resolve_skill_commands_platform and get_skill_commands that the
existing test_get_skill_commands_rescans_when_platform_scope_changes
test does not exercise.

Suggested by @teknium1 in #15375 (closed in favor of #18739) — the
original tests on #15375 were tied to the per-platform-cache approach
and don't translate, so this PR adds fresh tests targeting the merged
rescan-based implementation instead.

Refs #14536, #18739.

Coverage gaps addressed

  1. Gateway session context (HERMES_SESSION_PLATFORM via ContextVar)
    _resolve_skill_commands_platform consults get_session_env after
    HERMES_PLATFORM, and the gateway sets that variable through
    set_session_vars (a contextvars.ContextVar), not os.environ.
    The new test uses set_session_vars / clear_session_vars to drive
    the actual gateway signal, and the disabled-skill stub reads via
    get_session_env so the cache rescan is proven against the real
    ContextVar path — not the legacy env-var fallback. A regression that
    swapped get_session_env for plain os.getenv would still pass an
    env-var-based test but break concurrent gateway sessions, which is
    the bug the ContextVar plumbing exists to prevent.
  2. Returning to no-platform-scope (CLI / cron / RL after a gateway
    session)
    — verifies that unsetting HERMES_PLATFORM after a
    telegram-scoped scan triggers a fresh unfiltered scan rather than
    re-serving the telegram view.
  3. Same-platform cache hit (no rescan) — wraps scan_skill_commands
    with a spy after the cache is primed and asserts call_count == 0
    across three consecutive get_skill_commands() calls under the same
    platform. Guards against a regression where the rescan condition
    simplifies to "always re-resolve" — a gateway serving consecutive
    telegram requests must not pay the scan cost per request.

Tests

  • 3 new tests in tests/agent/test_skill_commands.py::TestScanSkillCommands.
  • Full file passes 39/39 under scripts/run_tests.sh tests/agent/test_skill_commands.py.

Type of change

  • Tests

…ousResearch#14536)

The rescan-on-platform-change fix landed in NousResearch#18739 ships one regression
test that exercises the HERMES_PLATFORM env-var path. Three other code
paths in get_skill_commands / _resolve_skill_commands_platform have no
direct coverage; this commit adds a regression test for each.

- Gateway session context (HERMES_SESSION_PLATFORM via ContextVar): the
  resolver consults get_session_env after HERMES_PLATFORM, and the
  gateway sets that variable through set_session_vars (a ContextVar),
  not os.environ. The test uses set_session_vars / clear_session_vars
  to drive the actual gateway signal, and the disabled-skill stub reads
  the same value via get_session_env. A regression that swapped
  get_session_env for plain os.getenv would still pass an env-var-based
  test but break concurrent gateway sessions, which is the bug the
  ContextVar plumbing exists to prevent.
- Returning to no-platform-scope (CLI / cron / RL rollouts after a
  gateway session): the cached telegram view must be dropped and the
  unfiltered scan repopulated when HERMES_PLATFORM is unset again.
- Same-platform cache hit: consecutive calls under the same platform
  scope must NOT rescan. The rescan trigger is change in scope, not
  "always re-resolve" — a gateway serving many consecutive telegram
  requests should pay the scan cost once, not per request.

The third test wraps scan_skill_commands with a spy after the cache is
primed, so the assertion is on call_count == 0 across three subsequent
get_skill_commands() calls.

All 39 tests in tests/agent/test_skill_commands.py pass under
scripts/run_tests.sh.
@alt-glitch alt-glitch added type/test Test coverage or test infrastructure P3 Low — cosmetic, nice to have comp/agent Core agent loop, run_agent.py, prompt builder tool/skills Skills system (list, view, manage) labels May 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent loop, run_agent.py, prompt builder P3 Low — cosmetic, nice to have tool/skills Skills system (list, view, manage) type/test Test coverage or test infrastructure

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants