Repository navigation
Tell the agent to read the leaf skill again once its session's hooks run another copy of Leaf - #6757
Merged
Merged
Conversation
…run another copy of Leaf Claude Code loads a plugin's files from a copy in its cache as a process starts, as on a resume or a background job's wake, and at /reload-plugins, and a session can hand its delivery to another Leaf (session_runtime). The transcript carries over, so the agent keeps following the skill and references it read under the old copy while its hooks and leaf commands run the new one. Nothing told it. Each hook now records the plugin root it ran from (leases.mark_root). The first hook under another root compares the two copies' skills/leaf/ byte for byte and, where they differ or the old copy is gone, queues a notice naming the new copy's SKILL.md (hooks.copy_changed) on the queue the clerk and summary forks already use. The next prompt or tool boundary carries it beside the input it hands over, in a session holding a page, and takes it off the queue. The root has a session file of its own rather than living in the hooks mark or the lifecycle record. SessionEnd removes the hooks mark, and a new generation replaces the lifecycle record, so either would forget the old root across the resume or wake this notice is for; a hook's write to the lifecycle record would also change the snapshot its own readings compare against. The new file stays while a claim names the session, as the lifecycle does. Whether the session holds a page is asked by the hook that prints the notice, since a resumed session's claims stay inactive until its first prompt serves its pages again, after the hook that marked the root. An unchanged root costs each hook one small read.
leaf-agent
approved these changes
Nov 22, 2026
leaf-agent
left a comment
Collaborator
There was a problem hiding this comment.
On current main the hooks still hand themselves to the copy Claude Code installed since (session_runtime.installed_launcher). So until #6758 lands, a live session holding a page also gets this notice whenever that installed copy moves to a commit that touched skills/leaf/, which is most commits (156 of 805 on main over the last two weeks). The PR body names only wakes, resumes and checkout selections as triggers; with #6758 merged, those are the only ones left. Landing the two together, or #6758 first, keeps the notice to the cases the description names.
max-sixty
added a commit
that referenced
this pull request
Nov 26, 2026
Leaf no longer tells the agent to read the leaf skill again when the skill
its session's hooks ship changes. The skill text the agent read is the
harness's to keep or renew; Claude Code 2.1.332 has `/reload-skills`
("Pick up skills added or changed on disk during this session").
The maintainer asked how much the notice costs to maintain and proposed
dropping it. It landed on 2026-11-22 (#6757) and has needed a change in
each of #6782 (Codex's and Pi's in-place updates), #7061 and the previous
commit on this branch (a checkout's own skill). Over the last 30 days 444
of main's 2,093 commits touched skills/leaf, so nearly every update a
session picked up made it reread SKILL.md and its references. A command
whose interface changed still reports that through its own error or
`--help`, which is the agent's path for any command it misremembers.
Each hook now records only the root of the Leaf it runs (`leases.mark_root`,
`sessions/<digest>.root`), which `state.hooks_root` reads for a checkout's
right to act for the session and for a server's follow to another copy. The
hook no longer hashes the skill's 33 files on every call. The record's file
is renamed from `.skill` to `.root`. An older Leaf at this protocol reads only
`.skill`, so across the one update that ships this commit a page server from
the older copy doesn't see the newer copy's root and stays where it is, which
two versions of Leaf at one protocol may. The clerk queue's schema description drops the
notice, an annotation the protocol baseline carries without a bump.
The notice after a compaction (`hooks.reload_skill`) stays: it covers the
text a compaction dropped, not a skill that changed.
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.
When a session's Leaf hooks start running another copy of Leaf, and that copy's
skills/leaf/differs from the one before, the next prompt or tool boundary tells the agent to read the new copy'sSKILL.mdagain.A background job's wake or a resume starts a new process, which loads whichever copy Claude Code has installed, and a checkout selection moves a session's hooks to that checkout. The transcript carries over in both cases, so the agent kept following the skill text it had read under the old copy, with nothing telling it the commands and rules may have changed.
Each hook records the plugin root it ran from in a session file of its own (
leases.mark_root). That file outlives the process while a claim names the session, unlike the hooks mark (removed at SessionEnd) and the lifecycle record (replaced on resume). The first hook under another root compares the two skill trees and queues the notice on the clerk queue. The prompt or tool-boundary hook then prints it beside any delivery, in a session holding a page. An unchanged root costs each hook one small read.Worth weighing: a session that holds no page keeps the notice queued until it next holds one. Two root changes before a printing hook, or a compaction at the same moment, give two notices.
The maintainer asked for this on the Leaf page about keeping a session on one version of Leaf (open item #11). Tests:
tests/model/test_hooks.py::test_a_hook_from_another_copy_sends_the_agent_back_to_the_skill, plus the focused hook, clerk, lifecycle, registration, fork and claim suites (214 passed).