Skip to content

feat(sleep): harvest Claude Skill tool invocations - #182

Merged
Yif-Yang merged 1 commit into
microsoft:mainfrom
bogdanbaciu21:skoc-001-harvest-claude-skill-tool-use
Jul 29, 2026
Merged

feat(sleep): harvest Claude Skill tool invocations#182
Yif-Yang merged 1 commit into
microsoft:mainfrom
bogdanbaciu21:skoc-001-harvest-claude-skill-tool-use

Conversation

@bogdanbaciu21

Copy link
Copy Markdown
Contributor

Summary

SessionDigest records every tool_use block's tool name in tools_used and
discards the block input, so a Claude Skill invocation is indistinguishable
from ordinary tool use after harvesting. This is the first review-sized slice of
the harvest work discussed in #120.

  • add an optional, default-empty SessionDigest.skills_used field;
  • harvest only well-formed Claude Skill tool-use blocks (type == "tool_use",
    name == "Skill", mapping input, non-blank string input.skill);
  • normalize by trimming surrounding whitespace and de-duplicating in first-seen
    order, preserving the skill name's case and punctuation;
  • keep tools_used behavior unchanged, including retaining Skill there, so no
    current consumer loses information.

No loader change is needed: skillopt_sleep/__main__.py filters pinned-digest
payload keys through SessionDigest.__dataclass_fields__, and the new field's
default covers older payloads that omit it.

Out of scope for this slice (kept for later slices of #120): TaskRecord
skill hints, per-skill grouping, SKILL.md path resolution, staging/adoption
changes, and Skill extraction in the Codex/Cursor harvesters.

Tests

  • python -m pytest -q tests/test_sleep_skill_harvest.py → 11 passed
  • python -m pytest -q → 567 passed, 7 skipped (base main at
    8304e6c: 556 passed, 7 skipped)
  • python -m ruff check skillopt_sleep/types.py skillopt_sleep/harvest.py tests/test_sleep_skill_harvest.py
    reports only the pre-existing I001 import-block finding already present on
    main for skillopt_sleep/harvest.py.

New coverage: field default and serialization, legacy payload without
skills_used, an older known-field filter ignoring the new key, positive
harvest, duplicate collapse, whitespace trimming without rewriting the name,
ordinary tools never populating skills_used, malformed blocks (lowercase tool
name, non-tool_use type, missing/non-mapping input, non-string or blank
input.skill, non-dict block), non-fatal malformed JSONL, and the guarantee
that other tool arguments and tool outputs stay out of the digest.

Refs #120

Add a backward-compatible SessionDigest.skills_used field and populate it
from well-formed Claude Skill tool-use blocks only. tools_used behavior and
legacy digest payload loading are unchanged.

Refs microsoft#120
Copilot AI review requested due to automatic review settings July 28, 2026 16:26

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends SkillOpt-Sleep’s session-harvesting digest to explicitly track Claude Skill tool invocations (skills_used) so downstream stages can distinguish “which skills were targeted” from general tool usage, supporting the broader multi-skill routing work in #120.

Changes:

  • Add SessionDigest.skills_used (default empty) and include it in serialization.
  • Harvest only well-formed Claude Skill tool-use blocks, trimming whitespace and de-duplicating in first-seen order.
  • Add deterministic stdlib-only tests covering positive/negative/malformed harvesting and backwards compatibility with legacy payloads.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
tests/test_sleep_skill_harvest.py Adds comprehensive unit tests for skills_used defaults/serialization and robust harvesting behavior.
skillopt_sleep/types.py Introduces SessionDigest.skills_used as a new default-empty field serialized via to_dict().
skillopt_sleep/harvest.py Implements skill-name extraction from Claude Skill tool-use blocks and wires it into transcript digesting with de-duplication.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@bogdanbaciu21

Copy link
Copy Markdown
Contributor Author

@microsoft-github-policy-service agree

@Yif-Yang
Yif-Yang merged commit 7da46ae into microsoft:main Jul 29, 2026
1 check passed
@bogdanbaciu21

Copy link
Copy Markdown
Contributor Author

THANK YOU!!!

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.

3 participants