Fix/replay persisted subagents - #1020
Open
euri10 wants to merge 2 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes session/load replay so it includes tool calls performed inside persisted Claude subagent transcripts, by loading subagent histories and interleaving them into the main session history before emitting session/update replays (preserving existing capability filtering and parentToolUseId attribution).
Changes:
- Load persisted subagent IDs via
listSubagents()and fetch their transcripts viagetSubagentMessages(). - Interleave subagent transcripts immediately after the launching
Agent/Tasktool call (recursively), then replay the combined history. - Add a regression test ensuring a child tool call from a persisted subagent is replayed and correctly attributed to its parent tool call.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/acp-agent.ts |
Loads persisted subagent transcripts and interleaves them into replay history so nested tool calls are replayed during session/load. |
src/tests/acp-agent.test.ts |
Adds a regression test covering split-storage replay (main transcript + persisted subagent transcript) to ensure child tool calls are restored with correct parentToolUseId. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
Summary
Fix
session/loadreplay losing tool calls made inside persisted Claudesubagents.
Problem
The ACP
session/loadcontractrequires the agent to replay the entire conversation through
session/updatenotifications. Tool executions are represented by
tool_callupdates.Claude stores subagent messages separately from the main session transcript:
getSessionMessages()returns the main transcript.listSubagents()discovers persisted subagents.getSubagentMessages()returns each subagent transcript.replaySessionHistory()only loaded the main transcript. As a result, a nestedtool call appeared during the original live turn but silently disappeared when
the same session was loaded. The parent Agent/Task result remained visible,
making the replay look complete while omitting the subagent's actual work.
This affected the adapter's
nested subagent transcript behavior.
The client capability controls whether nested updates are rendered or flattened;
it does not transfer session-history recovery to the client.
Fix
listSubagents().getSubagentMessages().tool call.
parentToolUseIdattribution remain unchanged.Regression test
The commits intentionally preserve red/green ordering:
fece865adds a split-storage regression fixture matching the Claude SDK'spersisted-session layout.
Before the implementation, the test fails:
e8f2df4adds the implementation and makes the same test pass.Real-session ACP evidence
The original live session emitted the nested call with its parent relationship:
{ "method": "session/update", "params": { "sessionId": "<redacted>", "update": { "sessionUpdate": "tool_call", "toolCallId": "toolu_01AB1x1SdnkvcFoPF6EcmTqr", "rawInput": { "command": "ls -d <project>/*/ | xargs -n1 basename | paste -sd, -" }, "_meta": { "claudeCode": { "parentToolUseId": "toolu_018NnXLu4qGQc7e4bei8C52a" } } } } }Before this fix, loading the same session emitted no corresponding child
tool_callupdate. After this fix, the child update is replayed with itsparent attribution and appears in the exported transcript in the expected
parent → child → assistant order.
Full logs are not included because they contain session content and local
environment details. The deterministic regression test provides reproducible
coverage; this excerpt documents the real ACP behavior that motivated it.
Verification
session/loadverification against a real persisted Claude session:nested child tool call restored with the correct parent ID