fix(memory): strip skill scaffolding for all providers, not just openviking

Generalizes #32663 (@ehz0ah). The slash-skill scaffolding pollution
affected every auto-syncing memory provider — mem0, hindsight, retaindb,
byterover, honcho, supermemory all store/embed the raw user turn, so a
/skill invocation poisoned their stores with the full skill body, not just
openviking.

- Lift the contributor's parser into agent/skill_commands.py as the canonical
  extract_user_instruction_from_skill_message(), co-located with the message
  builders so the markers can't drift.
- Strip once in MemoryManager.{prefetch_all,queue_prefetch_all,sync_all} —
  fixes the whole provider fan-out, bare /skill turns are skipped entirely.
- OpenViking's _derive_openviking_user_text() now delegates to the shared
  helper as defense-in-depth (no duplicated marker literals).
- Marker-drift regression now asserts against the canonical skill_commands
  constants; add manager-level coverage proving every provider gets clean text.
This commit is contained in:
Teknium
2026-06-16 07:59:49 -07:00
parent e3adbb5ae9
commit c2c55c4443
5 changed files with 296 additions and 60 deletions
+7 -7
View File
@@ -107,10 +107,10 @@ class TestOpenVikingSkillQuerySafety:
runtime_note="runtime detail",
)
assert single is not None
assert openviking_plugin._SKILL_INVOCATION_PREFIX in single
assert openviking_plugin._SINGLE_SKILL_MARKER in single
assert openviking_plugin._SINGLE_SKILL_INSTRUCTION in single
assert openviking_plugin._RUNTIME_NOTE in single
assert skill_commands._SKILL_INVOCATION_PREFIX in single
assert skill_commands._SINGLE_SKILL_MARKER in single
assert skill_commands._SINGLE_SKILL_INSTRUCTION in single
assert skill_commands._RUNTIME_NOTE in single
skill_bundles.scan_bundles()
bundle_result = skill_bundles.build_bundle_invocation_message(
@@ -119,9 +119,9 @@ class TestOpenVikingSkillQuerySafety:
)
assert bundle_result is not None
bundle, _, _ = bundle_result
assert openviking_plugin._BUNDLE_MARKER in bundle
assert openviking_plugin._BUNDLE_USER_INSTRUCTION in bundle
assert openviking_plugin._BUNDLE_FIRST_SKILL_BLOCK in bundle
assert skill_commands._BUNDLE_MARKER in bundle
assert skill_commands._BUNDLE_USER_INSTRUCTION in bundle
assert skill_commands._BUNDLE_FIRST_SKILL_BLOCK in bundle
def test_queue_prefetch_searches_only_slash_skill_user_instruction(self, monkeypatch):
RecordingVikingClient.calls = []