Commit Graph

4 Commits

Author SHA1 Message Date
Konstantin Khlopkov
2dbc44dfe0 fix(skills): convert skill command cache to multi-slot dict (platform/home identity isolation)
Fixes #104849

Converted `get_skill_commands()` from a single-slot cache (keyed by
`(platform, home)` tuple checked at call time) to a multi-slot dict
`_skill_commands_by_key = {(platform, home): {commands}}` that memoizes
each distinct identity once and serves it forever. The old single-slot
design thrashed in the Desktop `hermes serve` backend because the
platform/home identity flapped between requests (`HERMES_SESSION_PLATFORM`
set to `""` vs. resolved to `None`, profile home overrides) so every
`commands.catalog` poll (~3x/5s) re-scanned the entire skills dir.

Also normalized empty-string to `None` in `_resolve_skill_commands_platform()`
so both spellings share one cache slot (#104849 root cause), and replaced
direct `scan_skill_commands()` calls in `tui_gateway/methods_tools.py`
(two sites: `_catalog_skills`, `_dispatch_skill`) with `get_skill_commands()`
so they benefit from the cache instead of bypassing it.

- `tests/agent/test_skill_commands.py`: 30 tests green (updated monkeypatch
  fixtures from `_skill_commands*` globals to `_skill_commands_by_key`).
- New regression test `test_skill_cache_thrash_104849.py`: verifies that
  platform flapping (`""` ⇄ `None`) hits the same cache slot (scan once),
  and that distinct `(platform, home)` identities each get their own slot
  (preserves #14536 / #88023 isolation fixes).
- `test_skill_commands_reload.py`, `test_skill_invocation_description.py`,
  `test_prompt_cache_boundary.py`: green.
- `ruff check` on all modified files: clean.

Tested locally: after this patch the collision warning (skill `plan` vs.
core `/plan`) that repeated ~3x/5s while the Desktop window was focused
stopped entirely (zero scans mid-session), matching the issue reporter's
verification.
2026-09-29 18:05:05 -05:00
Brooklyn Nicholson
61fd2819b2 fix(skills): describe gateway auto-load scaffolds as the user's request
The gateway auto-load header ('[IMPORTANT: The "X" skill is auto-loaded.
Follow its instructions for this session.]') is scaffolding the describer
did not recognize: session previews showed the raw header + skill body,
the titler titled from the body, and 'hermes sessions retitle-skills'
never offered to repair auto-load sessions (#48359).

describe_skill_invocation now strips the payload (the built skill body
ends with the skill-directory footer note, so the LAST footer marks where
the user's typed text begins — a header quoted inside a body example
cannot end the payload early) and renders the typed request, or '/skill'
for a bare auto-load. Listing queries extend the scaffold LIKE predicate
so long auto-load rows get the same head+tail excerpt window, and the
retitle lookup finds auto-load sessions too.

Fixes #48359
2026-09-29 15:57:52 -05:00
Teknium
6b81590c55 test: prune low-value tests suite-wide (wave 1) — 46,820 → 28,106 test functions
Systematic prune per AGENTS.md test policy, one pass over every major
test tree (gateway, hermes_cli, tools, agent, run_agent, plugins, cli,
cron, tui_gateway, honcho/openviking, root-level):

- DELETE: source-reading tests (read_text/getsource on prod files),
  change-detector tests (exact catalog counts, model-name snapshots,
  config version literals), mock-echo tests (assert a mock returns what
  it was told), assertion-free/trivial tests, near-duplicate
  parametrizations (boundaries + one representative kept), async/sync
  twin duplicates, cosmetic within-file variations.
- KEEP (mandatory): security/redaction/approval guards, message-role
  alternation invariants, prompt-caching/deterministic-call-id
  invariants, issue-number regression tests (deduped), E2E tests.
- 6 test files deleted outright (script-style/no-assert or fully
  redundant); conftest.py, fakes/, fixtures/ untouched.
- tests/acp/conftest.py added: autouse fixture stubs the live
  models.dev/GitHub/Copilot/Anthropic inventory fetches that ACP server
  tests performed on every session create — test_server.py 147s → 3.4s,
  and the tests are now genuinely hermetic.
- Sleep-based slowness shrunk where safe (codex_ttfb_watchdog,
  compression_concurrent_fork, etc.); no wall-clock assertion tightened.

Verification: full hermetic suite via scripts/run_tests.sh —
2439 files, 31,130 tests passed, 0 failed, 0 flaky retries, 315s wall
(baseline: 583s wall, 13,564s subprocess CPU).
2026-07-29 13:10:23 -07:00
Brooklyn Nicholson
e4724ea455 feat(skills): describe a /skill turn the way the user typed it
A /skill invocation expands into a message that embeds the whole skill body.
Anything that summarizes a user turn from its raw content reads the skill's
prose as if the user had written it.

describe_skill_invocation() sits next to the existing extractor and reuses its
markers, returning `/work — fix the title leak` for an invocation with an
instruction and `/work` for a bare one. It also exports the SQL LIKE pattern
and excerpt-joint sentinel that listing queries need to recognize scaffolding
before a row reaches Python.
2026-07-26 02:58:12 -05:00