Repository navigation
perf(subagents): bound the parent-completion bookkeeping with a claim ledger - #744
Merged
Merged
Conversation
Refs #743 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Kk16MNVJtWAnCeGxGRuHqa
… ledger The sub-agent manager recorded every tool_result of the parent transcript into a per-session map that only the sidecar watcher ever consulted, for the handful of ids belonging to Agent sub-agents, and nothing trimmed it — tens of thousands of retained entries per long session. A CompletionLedger keeps a bounded recent window (2,048 results, enough to cover a result landing before its sidecar is discovered) and promotes an id to a never-evicted claimed tier on the watcher's first lookup, so a finished sub-agent cannot flip back to running once its result was seen. Fixes #743 Refs #327, #365, #288 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Kk16MNVJtWAnCeGxGRuHqa
…n end to end Review of #744 asked for two contracts the unit tests left implicit: a re-recorded id is treated as most recently used rather than keeping its old age, and the manager still reports a sub-agent done when the parent's result arrived before the sidecar was discovered and thousands of unrelated results followed — the claimed tier is what makes that hold. Also corrects the header's "poll is seconds" wording: the watcher polls every 600 ms and the window is bounded in results, not time. Refs #743 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Kk16MNVJtWAnCeGxGRuHqa
Owner
Author
|
Review feedback applied in the latest commit:
|
4 tasks
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.
Problem
SubAgentWatcherManager.observeParentEntry(src/main/subagents/index.ts) recorded everytool_resultof the parent transcript into a per-session map — Read, Bash, Edit, Grep, all of it — although the only consumer,SubAgentWatcher.parentResult(toolUseId), ever asks about the handful of ids that belong toAgentsidecars. Nothing trimmed it; it was cleared only when the session stopped. A heavy 24-hour session performs tens of thousands of tool calls: ~1.5–7 MB of retained strings per session, 30–140 MB across twenty, growing for the life of each session. Details in #743.What changed
src/main/subagents/completionLedger.ts:record(toolUseId, status)keeps results in a bounded recent LRU (2,048) — enough to cover a result landing before its sidecar file is discovered by the poll — andlookup(toolUseId)promotes a hit to a never-evictedclaimedtier, bounded by the number of sub-agents the session ever had. A finished sub-agent therefore cannot flip back to "running" once its result has been seen, which matters because the watcher recomputes done/error fromlookupon every emit.recordon a claimed id updates it in place.record's changed-flag drives the existing watcher refresh nudge; stop/stopAll unchanged.Linked issues
Fixes #743. Refs #327 (hypothesis 1: a sibling accumulator), #365, #288, #103.
Verification
NODE_ENV=test npx vitest run --project unit src/main/subagents/— 22 tests passed: the existing watcher, Codex tracker and shared suites plus the new ledger contracts (changed-flag semantics; oldest unclaimed results evicted at the cap; a claimed id survives any number of later records; in-place update of a claimed status; unknown id is undefined; non-positive window rejected).npx tsc -p tsconfig.node.json --noEmit— clean.Known limitations
Plan:
docs/superpowers/plans/2026-09-03-subagent-completion-ledger.md.🤖 Generated with Claude Code
https://claude.ai/code/session_01Kk16MNVJtWAnCeGxGRuHqa