Skip to content

Lead build step 1 follow-ups (T255) - #121

Merged
erickb336 merged 7 commits into
mainfrom
sage/t255-lead-followups
Oct 12, 2026
Merged

erickb336 merged 7 commits into
mainfrom
sage/t255-lead-followups

Conversation

@erickb336

@erickb336 erickb336 commented Oct 11, 2026 •

Copy link
Copy Markdown
Owner

Closes #102

The follow-ups to the lead build's step 1 (the nested spawn rules in the sage hook). No sage:lead agent exists yet, so none of these rules is live today.

Items and their tests (scripts/sage-hook.test.mjs)

Each test sends hook events to handle() through the built hook. Each one fails on main (fb48e83) and passes on this branch.

Item Change Test
H1 A child's events renew its lead's slot. A lead's slot does not expire while one of its children has a live slot. T255 H1: a child's events renew its lead's slot, and a lead with a running child keeps its slot
H2 An agent's spawn of a sage: type meets the nested rules in any mode: only a lead starts it, only the five team roles, the brief check and a slot. The main session outside sage mode is unchanged. T255 H2: outside sage mode, an agent that is not a lead starts no sage agent; a lead keeps the brief check
M1 A lead's stop frees only its own slot. A child keeps its slot until its own stop or its lease. T255 M1: a lead's stop does not free its running children's slots
M2 In sage mode, and for a sage agent in any mode, an agent sends SendMessage only to main: a message can wake a stopped agent outside every cap, and the event cannot tell a stopped target from a live one. The refusal says to start a fresh child or report to the sage. A plain agent outside sage mode, and the main session, are unchanged. This is the same scope as the nested spawn rule. T255 M2: a sage agent, or any agent in sage mode, sends SendMessage only to main; plain use outside sage mode is unchanged
M3 Only the main session's TaskStop frees a slot. T255 M3: only the main session's TaskStop frees a slot
L1 In sage mode, the main session starts sage:lead only with the name lead-T<n>: the Agent tool's name field, or description when there is no name. The check that the task has a running lead run needs step 2; it is left to #118. T255 L1: the main session starts a lead only with the name lead-T<n>
L2 A failed exact spawn frees its slot, also after a start of the same role. A pending slot with no start sign frees after 10 minutes. T255 L2: a spawn that never starts frees after 10 minutes, and a failed spawn frees at once

The hook manifest (claude.json) now sends SendMessage to the hook on PreToolUse. A new slot's time now comes from the hook's clock, not the file system's.

Four old assertions changed, because they held the behaviour that M1 and L2 change. Lead spawns in the old tests now use the name lead-T<n>.

Repair round 1

Each test fails on the commit before the fix (351cfd3, the merge of main) and passes after it.

Finding Change Test
F-T255-7 The main session starts sage:lead only with run_in_background: true. A foreground lead's slot binds only when the lead ends, so its children's events could not renew it. F-T255-7: the main session starts a lead only in the background
F-T255-4 In sage mode, and for a sage agent in any mode, an agent never names a spawn main (any letter case, after trimming): the name field, or description when there is no name. A plain agent outside sage mode keeps its normal use, the same scope as the SendMessage rule. F-T255-4: a sage agent, or any agent in sage mode, never names a spawn main; plain use outside sage mode is unchanged
F-T255-5 OURS is case-insensitive, and the spawned type is compared in lower case (the brief check, the lead name and background checks, the lead count, and the team list). The caller's sage:lead check and the chief check stay exact-case: a case-insensitive match there would give lead or chief rights to another type. F-T255-5: a sage type in another letter case meets the same spawn and message rules

Repair round 2

Each test fails on 3b8c747 and passes after the fix.

Finding Change Test
F-T255-10 In sage mode, or from a sage agent, a spawn named lead-T<n> (trimmed, any case) is refused like main. One reservedName function, one refusal sentence. The main session's own lead spawns are unchanged. F-T255-10: a sage agent, or any agent in sage mode, never names a spawn lead-T<n>; plain use outside sage mode is unchanged
F-T255-12 The main session's TaskStop frees the named agent's slot, also an exact slot (a lead's or a nested child's). An agent's TaskStop still frees nothing. The old T181 test now sends that TaskStop from a lead. F-T255-12: the main session's TaskStop frees a lead's slot; an agent's TaskStop frees none
F-T255-13 The slot store compares roles in lower case (take and matching), so a child that reports Sage:QA keeps its slot through its events. F-T255-13: a child whose type comes in another letter case keeps its slot through its events

Not verified live

  • SendMessage: the shape of its hook event from a real subagent (the test uses the documented to field). The sage runs that check.
  • That a nested child fires SubagentStart, or a tool event, in its first 10 minutes. The 10-minute grace depends on it.
  • That a failed foreground Agent call leaves no running agent.
  • Which field (name or description) the chief's Agent tool sends for lead-T<n>.
  • Grandchild events, and a real lead (none exists yet).
  • That a TaskStop by the lead's name (lead-T<n>) frees its slot: the slot knows the agent id, not the name.

🤖 Generated with Claude Code

erickb336 and others added 5 commits October 11, 2026 16:51
… slots, SendMessage, TaskStop (T255)

- H1: a child's events renew its lead's slot; a lead's slot never expires while a child slot is live.
- H2: an agent's spawn of a sage: type meets the lead rules, the brief check and the slot in any mode.
- M1: a lead's stop frees only its own slot; children keep theirs until their own stop or lease.
- M2: an agent's SendMessage (not to main) is a spawn: only a lead, a full brief, a slot.
- M3: only the main session's TaskStop frees a slot.
- L1: the main session starts sage:lead only as lead-T<n> (name, else description).
- L2: a failed exact spawn frees its slot; a pending slot with no start sign frees after 10 minutes.

Closes #102

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… (T255)

The chief chose option (c) for Q2: a message to a live child must not take a
second slot, and the event cannot tell a stopped target from a live one. The
hook now refuses an agent's SendMessage to anyone but main, in any mode, and
says to start a fresh child or report to the sage. PostToolUseFailure no
longer needs SendMessage.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ent (T255)

A plain agent outside sage mode is the owner's normal Claude use. The
SendMessage rule now has the scope of the nested spawn rule: sage mode on,
or a sage: caller in any mode.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…any case (T255)

- F-T255-7: the main session starts sage:lead only with run_in_background true,
  so the lead's slot binds at once and its children's events renew it.
- F-T255-4: an agent never names a spawn "main" (any case, trimmed), in the
  name, or the description when there is no name.
- F-T255-5: the sage type check is case-insensitive for the spawned type and
  the caller; the caller's lead check and the chief check stay exact-case.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… agent (T255)

A plain agent outside sage mode keeps its normal use, the same scope as the
SendMessage rule.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…oles in any case (T255)

- F-T255-10: in sage mode or from a sage agent, a spawn named lead-T<n> is
  refused like main (one reservedName function, one refusal sentence).
- F-T255-12: the main session's TaskStop frees the named agent's slot, also
  an exact (lead or child) slot; an agent's TaskStop still frees nothing.
- F-T255-13: the slot store compares roles in lower case, so a child that
  reports its type in another case keeps its slot through its events.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@erickb336
erickb336 merged commit fa94a05 into main Oct 12, 2026
1 check passed
@erickb336
erickb336 deleted the sage/t255-lead-followups branch October 12, 2026 02:26
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.

Lead build step 1 follow-ups: idle leads lose slots, spawn rules check the caller not the type, children outlive their lead's slots (before step 2)

1 participant