Repository navigation
feat: include Claude Code sub-agent work in the parent session (#77) - #154
Merged
Merged
Conversation
Sidechain records - a sub-agent's conversation, written into the same file as its parent - kept only their tool calls and the results that grade them, marked byAgent and inserted right after the Task call that launched the sub-agent. The sub-agent's prompt (written by the parent agent) and its narration are never read as a request, sidechain usage stays out of the parent's totals, and the event cap still holds.
This was referenced Nov 20, 2026
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.
What changed and why
Claude Code sub-agents write their conversation into the parent transcript as
isSidechainrecords, and the adapter skipped them wholesale — so workflows that delegate looked empty. Now the sub-agent's work is folded into the parent session, the same wayCursorAdapterfolds agent work into the chat.What is kept: only the sub-agent's shell, file and tool calls, plus the
tool_resultrecords that grade them (markResult, soisErrorflows into verified outcomes exactly as for parent calls). Each is markedbyAgent: true.What is never read: the sub-agent's prompt (written by the parent agent, not the developer — so no request), and its narration text.
Placement and caps: the events splice into the session right after the
Tasktool call that launched the sub-agent (tracked during the main parse; a file with several sessions uses the earliest launch).MAX_EVENTS_PER_SESSIONstill holds — the spliced slice is capped to the remaining room, so a chatty sub-agent cannot crowd out the parent's own events. Sidechain usage stays out of the parent's totals deliberately: whether sub-agent tokens belong in a session's cost is a question forreflex impact, not the event stream (noted indocs/architecture.md).Found and fixed while testing: my first cut duplicated the uuid-dedup block, which silently skipped every record in the file — the fixture test caught it immediately.
Docs
docs/architecture.md: the Claude Code paragraph (sidechain handling) and the usage paragraph (sidechain tokens deliberately excluded, with the reason).Testing
pnpm lint,pnpm typecheck,pnpm build,pnpm test: 751 passed, 18 skipped.byAgent: true, markedisErrorfrom the sub-agent's own failing result; the sub-agent's prompt is not a request and its narration is absent; ordering is launch → delegated → the parent's next call.MAX_EVENTS_PER_SESSIONand both sides survive.