File tree Expand file tree Collapse file tree
com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/chat Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -858,14 +858,14 @@ public void onChatProgress(ChatProgressValue value) {
858858
859859 // Cache conversation progress on report
860860 if (persistenceManager != null ) {
861- persistenceManager . cacheConversationProgress ( this . conversationId , value );
862-
863- // Set subagentToolCallId on subagent CopilotTurnData for restoration
864- if ( StringUtils . isNotBlank ( value . getParentTurnId ())
865- && StringUtils .isNotBlank (this . lastRunSubagentToolCallId )) {
866- persistenceManager .setSubagentToolCallId (this .conversationId , value .getTurnId (),
867- this . lastRunSubagentToolCallId );
868- }
861+ // Chain setSubagentToolCallId after cacheConversationProgress to avoid race condition
862+ // where the subagent CopilotTurnData hasn't been created yet
863+ final String subagentToolCallId = this . lastRunSubagentToolCallId ;
864+ persistenceManager . cacheConversationProgress ( this . conversationId , value ). thenRun (() -> {
865+ if ( StringUtils . isNotBlank ( value . getParentTurnId ()) && StringUtils .isNotBlank (subagentToolCallId )) {
866+ persistenceManager .setSubagentToolCallId (this .conversationId , value .getTurnId (), subagentToolCallId );
867+ }
868+ });
869869 }
870870 break ;
871871 case end :
You can’t perform that action at this time.
0 commit comments