Skip to content

fix - subagent progress isolation, persistence, and restoration during session switching#166

Merged
jdneo merged 4 commits into
mainfrom
tori/persist-subagent
May 11, 2026
Merged

fix - subagent progress isolation, persistence, and restoration during session switching#166
jdneo merged 4 commits into
mainfrom
tori/persist-subagent

Conversation

@xinyi-gong

@xinyi-gong xinyi-gong commented May 9, 2026

Copy link
Copy Markdown
Member

fix #160, #163

Summary

Fixes subagent progress events leaking into unrelated conversations when switching sessions, adds conversation/destroy to stop CLS processing on cancel/switch, and correctly persists and restores subagent execution content inside SubagentMessageBlock cards.

Changes

Progress event isolation

  • Add isProgressForCurrentConversation() to filter report/end events by conversationId, with subagent awareness via subagentConversationId
  • Auto-set subagentConversationId on first subagent event
  • Add ConversationDestroyParams and conversation/destroy LSP method
    onCancel() sends destroyConversation() to CLS for both main and subagent conversations, stopping server-side LLM calls
  • Reset send button in onCancel() to prevent stuck cancel state

Subagent persistence

  • Add parentTurnId and subagentToolCallId fields to CopilotTurnData
  • Mark subagent progress with parentTurnId during cacheConversationProgress
  • Track lastRunSubagentToolCallId from run_subagent tool calls and associate with subagent CopilotTurnData
  • Skip subagent turns in convertToTurns() (not part of main conversation history sent to CLS)

Subagent restoration

  • restoreTurn(): subagent CopilotTurnData (with parentTurnId) renders inside the parent turn's SubagentMessageBlock via restoreSubagentContent()
  • handleSubagentToolCall(completed): creates SubagentMessageBlock for restoration path (no prior running status in persisted data)
  • BaseTurnWidget.subagentBlocks map stores blocks by tool call ID for precise content injection
  • Extract restoreCopilotTurnContent() as shared method for main and subagent turns

Test plan

  • Add subagent.md with 5 test cases covering live execution, persistence, session switching, cancel, and multi-subagent scenarios

@xinyi-gong xinyi-gong marked this pull request as ready for review May 9, 2026 08:42
@xinyi-gong xinyi-gong requested a review from jdneo as a code owner May 9, 2026 08:42
Copilot AI review requested due to automatic review settings May 9, 2026 08:42

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes subagent progress/event routing and persistence so that subagent execution stays scoped to the correct conversation during session switching, and restores subagent output nested under the parent run_subagent card when loading history.

Changes:

  • Add conversation-scoped progress filtering (isProgressForCurrentConversation) and send conversation/destroy on cancel/switch to stop server-side processing.
  • Persist subagent linkage metadata (parentTurnId, subagentToolCallId) and skip subagent turns when rebuilding main-conversation history for CLS.
  • Restore persisted subagent output into the parent turn’s SubagentMessageBlock via tool-call-id keyed block lookup.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/chat/ChatView.java Filters progress events by conversation/subagent conversation and restores subagent turns into parent blocks; adds destroy on cancel.
com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/chat/BaseTurnWidget.java Tracks subagent blocks by toolCallId and provides a restoration injection path.
com.microsoft.copilot.eclipse.swtbot.test/test-plans/subagent/subagent.md Adds a manual test plan covering live execution, persistence, switching, and cancel scenarios.
com.microsoft.copilot.eclipse.core/src/com/microsoft/copilot/eclipse/core/persistence/CopilotTurnData.java Persists parentTurnId and subagentToolCallId for restoration/linking.
com.microsoft.copilot.eclipse.core/src/com/microsoft/copilot/eclipse/core/persistence/ConversationPersistenceManager.java Marks subagent turns with parentTurnId and adds async setter for subagentToolCallId.
com.microsoft.copilot.eclipse.core/src/com/microsoft/copilot/eclipse/core/persistence/ConversationDataFactory.java Excludes subagent turns from the turn list sent back to CLS.
com.microsoft.copilot.eclipse.core/src/com/microsoft/copilot/eclipse/core/lsp/protocol/ConversationDestroyParams.java Introduces params type for conversation/destroy.
com.microsoft.copilot.eclipse.core/src/com/microsoft/copilot/eclipse/core/lsp/CopilotLanguageServerConnection.java Adds client helper to call conversation/destroy.
com.microsoft.copilot.eclipse.core/src/com/microsoft/copilot/eclipse/core/lsp/CopilotLanguageServer.java Adds the conversation/destroy JSON-RPC request.

xinyi-gong added 2 commits May 9, 2026 18:03
# Conflicts:
#	com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/chat/BaseTurnWidget.java

@jdneo jdneo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jdneo jdneo merged commit 44e86cd into main May 11, 2026
4 checks passed
@jdneo jdneo deleted the tori/persist-subagent branch May 11, 2026 05:13
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.

Subagent progress events leak into unrelated conversation UI when switching sessions

3 participants