Skip to content

COG-6311 feat: Add SKILLS search type and skill gate - #4662

Open
Vasilije1990 wants to merge 1 commit into
devfrom
Vasilije1990/improve_skills
Open

COG-6311 feat: Add SKILLS search type and skill gate#4662
Vasilije1990 wants to merge 1 commit into
devfrom
Vasilije1990/improve_skills

Conversation

@Vasilije1990

Copy link
Copy Markdown
Contributor

Description

Skills (dataset-scoped SKILL.md playbooks) are invisible outside the agentic retriever today: their embeddings in the Skill_search_text vector collection are written on every ingest but nothing ever searches them — the only reader is delete cleanup. This PR adds procedural-memory discovery on top of that existing index (no new indexing) plus a deterministic gate that surfaces skills automatically on procedural questions.

SearchType.SKILLS

SkillsRetriever (a SummariesRetriever-style clone) runs one vector search over Skill_search_text — no LLM call.

  • Strictly dataset-scoped: requires exactly one explicit dataset (validated in search() alongside the agentic check, and again at retriever construction). Payloads are filtered on dataset_scope membership and is_active; empty-scope legacy skills are excluded. Re-ingesting (an upsert) makes legacy skills visible again.
  • Metadata-only results: name, description, maintainer, version, tags, license, declared tools, and the vector score. procedure/skill_text/search_text are stripped — full bodies stay behind the load_skill tool or GET /skills/{skill_id}, preserving the progressive-disclosure design.
  • A missing collection returns [] (deliberate divergence from SUMMARIES' NoDataError): "no skills ingested" is a normal state and the gate path must degrade to a no-op.
  • Exposed in the SDK, recall(query_type=...), and cognee-cli search --query-type SKILLS.

Deterministic skill gate in recall()

cognee/api/v1/recall/skill_gate.py — weighted regexes with the query router's negation suppression; no LLM, no I/O. Procedural phrasing ("how do I…", "steps to…", "runbook", "walk me through…") fires it; a bare ops verb alone does not.

When it fires and exactly one dataset is targeted, a metadata-only SKILLS lookup runs concurrently with the main lanes and hits are appended as ResponseSkillEntry tagged source="skills". Additive only — the main answer never waits on it, gate failures are swallowed, explicit SKILLS/AGENTIC queries bypass it, and SKILL_GATE_ENABLED=false turns it off. The auto-router is untouched (routing to SKILLS would replace answers with listings).

Tests

36 new unit tests, all green (retriever scope/active filtering, empty-scope exclusion, over-fetch trim, dedupe, body-stripping projection, sparse legacy payloads, missing collection; gate classification table, negation, env flag; six recall-wiring tests including gate-failure isolation and the single-dataset skip). Affected suites pass: 624 tests across tools/skills-router/recall/retrieval, 118 across search+gate+retriever, 13 CLI search tests.

README and CLAUDE.md document the feature inline.

🤖 Generated with Claude Code

Skills (dataset-scoped SKILL.md playbooks) were invisible outside the
agentic retriever: their embeddings in the Skill_search_text collection
were written on ingest but never searched. This adds procedural-memory
discovery on top of the existing index — no new indexing.

- SearchType.SKILLS: one vector search, no LLM. Requires exactly one
  explicit dataset (same invariant as the agentic skill loader) and
  filters strictly on dataset_scope + is_active; empty-scope legacy
  skills are excluded. Results are metadata-only (name, description,
  maintainer, tags, declared tools, score) — procedure bodies stay
  behind load_skill / GET /skills/{id} to preserve progressive
  disclosure. A missing collection returns [] instead of NoDataError
  so skill-less datasets degrade silently.
- Skill gate in recall(): a deterministic weighted-regex gate (no LLM,
  no I/O) detects procedural queries and runs a concurrent metadata-only
  SKILLS lookup, appending hits tagged source="skills". Additive and
  fail-safe; only fires when exactly one dataset is targeted; disable
  with SKILL_GATE_ENABLED=false.
- Wiring: retriever registry, result normalization (kind "skill"),
  ResponseSkillEntry in the recall response union, CLI --query-type
  choice, and the exactly-one-dataset validation in search().
- 36 new unit tests (retriever filtering/projection, gate
  classification, recall wiring); README and CLAUDE.md document the
  feature.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant