Skip to content

fix: clean up auto-activated skills per turn and sync skill tools#257

Merged
veithly merged 3 commits intomainfrom
fix/skill-perf-cleanup
Feb 9, 2026
Merged

fix: clean up auto-activated skills per turn and sync skill tools#257
veithly merged 3 commits intomainfrom
fix/skill-perf-cleanup

Conversation

@veithly
Copy link
Collaborator

@veithly veithly commented Feb 9, 2026

Summary

This PR fixes the main causes of slow and off-topic responses in SpoonReactSkill skill execution.

Root causes addressed

  1. Auto-activated skills were never cleaned up after each turn
  2. Skill tools were injected one-way and stale tools were never removed
  3. Intent matching ran even when trigger matching already succeeded

Changes

  • Add per-turn skill lifecycle wrapper in SkillEnabledMixin:
    • _run_with_auto_skills() auto-activates for current turn and auto-deactivates in finally
  • Add robust tool synchronization:
    • _sync_skill_tools() now adds missing active skill tools and removes stale tool injections
    • Keep _inject_skill_tools() as backward-compatible alias
  • Make deactivation flow sync tools immediately
  • Optimize matching in SkillManager.find_matching_skills():
    • Run LLM intent analysis only as fallback when trigger matches are empty
  • Add safe no-op in ToolManager.remove_tool() when tool name does not exist
  • Add include_default_paths support in skill loading stack:
    • SkillLoader(..., include_default_paths=True)
    • SkillManager(..., include_default_paths=True)
  • Add regression tests in tests/test_skills.py for:
    • Ephemeral auto-activation cleanup
    • Stale skill tool removal after deactivation
    • Intent fallback skipping when trigger already hits
  • Add SKILL_PERF_ANALYSIS.md with root-cause analysis and expected impact

Validation

  • Ran skill test suite:
    • /home/google/project/spoon-bot/.venv/bin/python -m pytest tests/test_skills.py -q
    • Result: 82 passed

Notes

  • Existing unrelated failures in other test modules were not modified by this PR.
  • This PR is scoped specifically to skill activation lifecycle, tool synchronization, and matching efficiency.

Root causes of slow/off-topic skill responses:
1. Auto-activated skills never cleaned up after each turn
2. Skill tools injected but never removed on deactivation
3. LLM intent matching ran even when trigger matches existed

Changes:
- Add _run_with_auto_skills() for ephemeral per-turn activation/cleanup
- Add _sync_skill_tools() to add/remove tools in sync with active skills
- Skip LLM intent analysis when keyword triggers already match
- Add include_default_paths flag to SkillLoader/SkillManager
- Make ToolManager.remove_tool() safe on missing tools
- Add tests for ephemeral activation, stale tool removal, intent fallback
- Add SKILL_PERF_ANALYSIS.md documenting root causes and fixes
@veithly veithly merged commit 6d150a2 into main Feb 9, 2026
1 check passed
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