feat(sleep): harvest Claude Skill tool invocations - #182
Merged
Yif-Yang merged 1 commit intoJul 29, 2026
Merged
Conversation
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
Contributor
There was a problem hiding this comment.
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
Skilltool-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.
This was referenced Jul 28, 2026
Contributor
Author
|
@microsoft-github-policy-service agree |
Contributor
Author
|
THANK YOU!!! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
SessionDigestrecords everytool_useblock's tool name intools_usedanddiscards the block input, so a Claude
Skillinvocation is indistinguishablefrom ordinary tool use after harvesting. This is the first review-sized slice of
the harvest work discussed in #120.
SessionDigest.skills_usedfield;Skilltool-use blocks (type == "tool_use",name == "Skill", mappinginput, non-blank stringinput.skill);order, preserving the skill name's case and punctuation;
tools_usedbehavior unchanged, including retainingSkillthere, so nocurrent consumer loses information.
No loader change is needed:
skillopt_sleep/__main__.pyfilters pinned-digestpayload keys through
SessionDigest.__dataclass_fields__, and the new field'sdefault covers older payloads that omit it.
Out of scope for this slice (kept for later slices of #120):
TaskRecordskill hints, per-skill grouping,
SKILL.mdpath resolution, staging/adoptionchanges, and Skill extraction in the Codex/Cursor harvesters.
Tests
python -m pytest -q tests/test_sleep_skill_harvest.py→ 11 passedpython -m pytest -q→ 567 passed, 7 skipped (basemainat8304e6c: 556 passed, 7 skipped)python -m ruff check skillopt_sleep/types.py skillopt_sleep/harvest.py tests/test_sleep_skill_harvest.pyreports only the pre-existing
I001import-block finding already present onmainforskillopt_sleep/harvest.py.New coverage: field default and serialization, legacy payload without
skills_used, an older known-field filter ignoring the new key, positiveharvest, duplicate collapse, whitespace trimming without rewriting the name,
ordinary tools never populating
skills_used, malformed blocks (lowercase toolname, non-
tool_usetype, missing/non-mappinginput, non-string or blankinput.skill, non-dict block), non-fatal malformed JSONL, and the guaranteethat other tool arguments and tool outputs stay out of the digest.
Refs #120