Skip to content

feat: include Claude Code sub-agent work in the parent session (#77) - #154

Merged
NehharShah merged 1 commit into
mainfrom
feat/claude-subagents
Nov 20, 2026
Merged

NehharShah merged 1 commit into
mainfrom
feat/claude-subagents

Conversation

@NehharShah

Copy link
Copy Markdown
Collaborator

What changed and why

Claude Code sub-agents write their conversation into the parent transcript as isSidechain records, 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 way CursorAdapter folds agent work into the chat.

What is kept: only the sub-agent's shell, file and tool calls, plus the tool_result records that grade them (markResult, so isError flows into verified outcomes exactly as for parent calls). Each is marked byAgent: 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 Task tool call that launched the sub-agent (tracked during the main parse; a file with several sessions uses the earliest launch). MAX_EVENTS_PER_SESSION still 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 for reflex impact, not the event stream (noted in docs/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.

  • Sub-agent tool events appear in the parent with byAgent: true, marked isError from 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.
  • The cap test: 400 delegated tool calls against a session with its own events — the total holds at MAX_EVENTS_PER_SESSION and both sides survive.
  • The old "drops sidechain records" test now asserts the part that still holds: a sidechain prompt is never a request.

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.
@NehharShah
NehharShah merged commit 4da2477 into main Nov 20, 2026
2 checks passed
@NehharShah
NehharShah deleted the feat/claude-subagents branch November 20, 2026 20:04
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.

1 participant