v0.41.0: SubagentStop budget feedback (env-gated, CC 2.1.163+)#39
Merged
Conversation
CC 2.1.163 added: "Stop and SubagentStop hooks can now return
hookSpecificOutput.additionalContext to give Claude feedback and keep
the turn going without being labeled a hook error." That unlocks
in-the-moment feedback from our v0.40.0 SubagentStop capture, useful
for the new dynamic-workflows era (a /workflow run fans out to tens-
hundreds of agents).
Verified against the user's installed bundle FIRST (the doctrine):
the active CC is 2.1.161, which does NOT support additionalContext
from SubagentStop — returning it there is labelled a hook error
(noise, the v0.34.0-args failure class). So this is strictly
env-gated, default OFF, and documented as 2.1.163+ only.
What it does (when TOKEN_PILOT_SUBAGENT_FEEDBACK=1 AND CC >= 2.1.163):
- decideSubagentFeedback(): when an active `token-pilot workflow`
is at >=90% of its token ceiling, returns a wind-down note so a
large fan-out stops dispatching new agents before the budget
blows. Silent otherwise — no nagging on every completion; broad
adoption nudges stay in SessionStart.
- renderSubagentFeedback(): wraps it in the SubagentStop
hookSpecificOutput shape.
- hook-subagent-stop emits it ONLY behind the env flag; the
default path (telemetry write only, v0.40.0) is unchanged and
safe on every CC version.
Pure logic is fully unit-tested; the CC-side emission can only be
verified once on 2.1.163 (the user is not there yet) — hence the flag.
Tests: 1333/1333 pass (+5).
Build: clean (25 agents under 0.41.0).
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.
CC 2.1.163 added: Stop and SubagentStop hooks can now return
hookSpecificOutput.additionalContext. Unlocks in-the-moment feedback from the v0.40.0 SubagentStop capture — useful for dynamic workflows (a/workflowrun fans out to tens–hundreds of agents).Doctrine applied — verified the binary FIRST. The user's active CC is 2.1.161, which does NOT support additionalContext from SubagentStop (returning it there = hook error, the v0.34.0-args class). So this is strictly env-gated, default OFF, documented 2.1.163+ only.
When
TOKEN_PILOT_SUBAGENT_FEEDBACK=1AND CC ≥ 2.1.163:decideSubagentFeedback()— when an activetoken-pilot workflowis at ≥90% of its token ceiling, returns a wind-down note so a large fan-out stops dispatching before the budget blows. Silent otherwise.Pure logic fully unit-tested; CC-side emission verifiable only on 2.1.163 (user not there yet) → hence the flag.
1333/1333 tests pass.