Heuristic:AMAP ML SkillClaw Skill Injection Effectiveness Ranking
| Knowledge Sources | |
|---|---|
| Domains | Optimization, LLMs |
| Last Updated | 2026-10-22 00:00 GMT |
Overview
Effectiveness-ranked skill retrieval that tracks injection/feedback statistics and uses a weighted scoring formula to rank skills by both relevance and past performance.
Description
SkillManager maintains per-skill statistics (`inject_count`, `positive_count`, `negative_count`, `neutral_count`, `effectiveness`) persisted in `skill_stats.json`. Skills are ranked by their effectiveness score (`positive_count / inject_count`, default 0.5 for unknown skills). In template mode, all skills are sorted purely by effectiveness. In embedding mode, the ranking combines cosine similarity with effectiveness using a weighted formula: `score = similarity * (0.3 + 0.7 * effectiveness)`, giving effectiveness 70% weight in the final ranking. Near-duplicate skills are deduplicated by embedding similarity (threshold 0.9). Stats are flushed to disk every 10 mutations to avoid excessive I/O.
Usage
Use this heuristic when choosing which skills to inject into agent system prompts. It ensures skills that have historically led to positive outcomes are prioritized over equally-relevant but untested or poorly-performing skills.
The Insight (Rule of Thumb)
- Action: Track per-skill injection and PRM feedback counts; rank by `effectiveness = positive / total_injections`.
- Value: Embedding mode weight: `0.3 * similarity + 0.7 * effectiveness` (effectiveness dominates). Dedup threshold: 0.9. Stats flush: every 10 mutations.
- Trade-off: New/untested skills default to 0.5 effectiveness, which may disadvantage genuinely good but unproven skills.
- Compatibility: Works in both template (effectiveness-only) and embedding (weighted) retrieval modes.
Reasoning
Not all skills that match a task description are equally helpful. Some may be outdated, poorly written, or misleading. By tracking PRM feedback (positive/negative/neutral) per skill injection, the system learns which skills actually help. The 70/30 weighting toward effectiveness ensures that a highly similar but poorly-performing skill is deprioritized in favor of a less similar but proven one. The 0.9 deduplication threshold prevents injecting multiple skills that say essentially the same thing, saving context window space.
Code Evidence
Weighted scoring from `skillclaw/skill_manager.py:456-459`:
def _weighted_score(self, similarity: float, skill_name: str) -> float:
eff = self.get_effectiveness(skill_name)
return similarity * (0.3 + 0.7 * eff)
Effectiveness tracking from `skillclaw/skill_manager.py:272-286`:
def record_feedback(self, skill_names: list[str], score: float) -> None:
for name in skill_names:
entry = self._stats.get(name)
if entry is None:
continue
if score > 0:
entry["positive_count"] += 1
elif score < 0:
entry["negative_count"] += 1
else:
entry["neutral_count"] += 1
total = entry["inject_count"]
entry["effectiveness"] = entry["positive_count"] / total if total > 0 else 0.5
Stats flush batching from `skillclaw/skill_manager.py:246-251`:
def _maybe_flush_stats(self) -> None:
self._stats_dirty += 1
if self._stats_dirty >= 10:
self._save_stats()
self._stats_dirty = 0