Repository navigation
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ks async Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
Author
|
Closed without merging: the project is moving to a minimal plugin (operator decision 2026-11-04), which this change no longer serves. The branch is kept for reference. |
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.
Phase 1a, T2 of the lean-mode scope (
docs/specs/lean-mode-scope.md§4 and §6a item 2).Problem
Dispatches and per-role spend are written by hand today, with a
dispatch_decisionper agent. That bookkeeping is a large part of the orchestrator's 40% share in the 2026-11-03 trial. §4 moves it into hooks.Change
SubagentStartandSubagentStopare registered async in.claude/hooks/hooks.jsonand callsubagent-hook.sh, which runs the leanbs-subagent-hookbin. Each hook always exits 0. Async hooks have no enforced timeout, and theirsystemMessagereaches the model on its next turn; INSTALL.md says so.subagent-startedrecordsagent_idandagent_type.subagent-stoppedrecords role, model, input/output/cache tokens,total_tokens(the delta since that agent's previous stop),cumulative_tokens,last_turn_tokensandcomplete.<cli>.jsonl. That log is created with the shared auto-root when needed, so the feat: optional --session and --causal-parent with safe defaults #533 guard sees the entry. A stop is written into the log that holds its agent's start.agents-registry.ts).agent_idby occurrence, in either arrival order.dispatch_decisionof its role, so/bs rundoes not double-count.epic-closedends every entry of the epic.agent-prefixes and transcript basenames both match.budgets.ymltask:cap, with the default tier scale applied. Checked against 275 real Agent-tool totals from one session: 82 matched exactly, 225 came within 2%, 1 warning was missed and none were false.bs subagent spend --session <id>gives spend by role, which the/bs dosummary will use.bs subagent stop --agent-id <id> --reason abandonedcloses a lost stop. The feat: optional --session and --causal-parent with safe defaults #533 refusal names it, together with the agent ids.bs budget alarmstays epic- and task-keyed and does not read these events. Feeding it would double-count under/bs run.Known follow-up
The direct closer can also close a running sibling, the same as hand-appending a stop. That hides the sibling from the #533 guard. It goes into the subagent guard item that is pending with the operator: refuse
subagent stop --agent-idandevent appendofsubagent-*when the PreToolUse input carriesagent_id.Review
A fresh-context review ran four rounds, with probes against the branch build:
/bs run, a sync 5 s timeout lost stops, the stop lookup missed logs, the guard was blind toprompts-<cli>, the cap formula was wrong, and id shapes were unverified;epic-closed, a real resume could be dropped, and cross-log resumes double-counted;Verification
heavy run: 277 files, 10932 passed, 2 skipped.usage.test.ts(301).typecheck,typecheck:testand biome at error level are clean.SubagentStart/SubagentStoppayload. That gets verified in a real session after merge.🤖 Generated with Claude Code