@@ -9,6 +9,7 @@ import { ChatFetchResponseType } from '../../../platform/chat/common/commonTypes
99import { ConfigKey , IConfigurationService } from '../../../platform/configuration/common/configurationService' ;
1010import { CapturingToken } from '../../../platform/requestLogger/common/capturingToken' ;
1111import { IRequestLogger } from '../../../platform/requestLogger/common/requestLogger' ;
12+ import { getCurrentCapturingToken } from '../../../platform/requestLogger/node/requestLogger' ;
1213import { IExperimentationService } from '../../../platform/telemetry/common/nullExperimentationService' ;
1314import { ChatResponseStreamImpl } from '../../../util/common/chatResponseStreamImpl' ;
1415import { generateUuid } from '../../../util/vs/base/common/uuid' ;
@@ -81,11 +82,17 @@ class ExecutionSubagentTool implements ICopilotTool<IExecutionSubagentParams> {
8182 // Create a new capturing token to group this execution subagent and all its nested tool calls
8283 // Similar to how DefaultIntentRequestHandler does it
8384 // Pass the subAgentInvocationId so the trajectory uses this ID for explicit linking
85+ const parentChatSessionId = getCurrentCapturingToken ( ) ?. chatSessionId ;
8486 const executionSubagentToken = new CapturingToken (
8587 `Execution: ${ options . input . query . substring ( 0 , 50 ) } ${ options . input . query . length > 50 ? '...' : '' } ` ,
8688 'execution' ,
8789 subAgentInvocationId ,
88- 'execution' // subAgentName for trajectory tracking
90+ 'execution' , // subAgentName for trajectory tracking
91+ // Use invocation ID as chatSessionId so spans get their own log file
92+ subAgentInvocationId ,
93+ // Link back to the parent session for debug log grouping and cloud session folding
94+ parentChatSessionId ,
95+ 'executionSubagent' ,
8996 ) ;
9097
9198 // Wrap the loop execution in captureInvocation with the new token
0 commit comments