@@ -15,6 +15,7 @@ public class PendingWorkResumeE2ETests(E2ETestFixture fixture, ITestOutputHelper
1515 : E2ETestBase ( fixture , "pending_work_resume" , output )
1616{
1717 private static readonly TimeSpan PendingWorkTimeout = TimeSpan . FromSeconds ( 60 ) ;
18+ private const string SharedToken = "pending-work-resume-shared-token" ;
1819
1920 [ Fact ]
2021 public async Task Should_Continue_Pending_Permission_Request_After_Resume ( )
@@ -23,11 +24,11 @@ public async Task Should_Continue_Pending_Permission_Request_After_Resume()
2324 var releaseOriginalPermission = new TaskCompletionSource < PermissionRequestResult > ( TaskCreationOptions . RunContinuationsAsynchronously ) ;
2425 var resumedToolInvoked = false ;
2526
26- await using var server = Ctx . CreateClient ( useStdio : false ) ;
27+ await using var server = Ctx . CreateClient ( useStdio : false , options : new CopilotClientOptions { TcpConnectionToken = SharedToken } ) ;
2728 await server . StartAsync ( ) ;
2829 var cliUrl = GetCliUrl ( server ) ;
2930
30- using var suspendedClient = Ctx . CreateClient ( options : new CopilotClientOptions { CliUrl = cliUrl } ) ;
31+ using var suspendedClient = Ctx . CreateClient ( options : new CopilotClientOptions { CliUrl = cliUrl , TcpConnectionToken = SharedToken } ) ;
3132 var session1 = await suspendedClient . CreateSessionAsync ( new SessionConfig
3233 {
3334 Tools = [ AIFunctionFactory . Create ( ResumePermissionTool , "resume_permission_tool" ) ] ,
@@ -54,7 +55,7 @@ await session1.SendAsync(new MessageOptions
5455
5556 await suspendedClient . ForceStopAsync ( ) ;
5657
57- await using var resumedTcpClient = Ctx . CreateClient ( options : new CopilotClientOptions { CliUrl = cliUrl } ) ;
58+ await using var resumedTcpClient = Ctx . CreateClient ( options : new CopilotClientOptions { CliUrl = cliUrl , TcpConnectionToken = SharedToken } ) ;
5859 var session2 = await resumedTcpClient . ResumeSessionAsync ( sessionId , new ResumeSessionConfig
5960 {
6061 ContinuePendingWork = true ,
@@ -106,11 +107,11 @@ public async Task Should_Continue_Pending_External_Tool_Request_After_Resume()
106107 var originalToolStarted = new TaskCompletionSource < string > ( TaskCreationOptions . RunContinuationsAsynchronously ) ;
107108 var releaseOriginalTool = new TaskCompletionSource < string > ( TaskCreationOptions . RunContinuationsAsynchronously ) ;
108109
109- await using var server = Ctx . CreateClient ( useStdio : false ) ;
110+ await using var server = Ctx . CreateClient ( useStdio : false , options : new CopilotClientOptions { TcpConnectionToken = SharedToken } ) ;
110111 await server . StartAsync ( ) ;
111112 var cliUrl = GetCliUrl ( server ) ;
112113
113- using var suspendedClient = Ctx . CreateClient ( options : new CopilotClientOptions { CliUrl = cliUrl } ) ;
114+ using var suspendedClient = Ctx . CreateClient ( options : new CopilotClientOptions { CliUrl = cliUrl , TcpConnectionToken = SharedToken } ) ;
114115 var session1 = await suspendedClient . CreateSessionAsync ( new SessionConfig
115116 {
116117 Tools = [ AIFunctionFactory . Create ( BlockingExternalTool , "resume_external_tool" ) ] ,
@@ -131,7 +132,7 @@ await session1.SendAsync(new MessageOptions
131132 Assert . Equal ( "beta" , await originalToolStarted . Task . WaitAsync ( PendingWorkTimeout ) ) ;
132133 await suspendedClient . ForceStopAsync ( ) ;
133134
134- await using var resumedClient = Ctx . CreateClient ( options : new CopilotClientOptions { CliUrl = cliUrl } ) ;
135+ await using var resumedClient = Ctx . CreateClient ( options : new CopilotClientOptions { CliUrl = cliUrl , TcpConnectionToken = SharedToken } ) ;
135136 var session2 = await resumedClient . ResumeSessionAsync ( sessionId , new ResumeSessionConfig
136137 {
137138 ContinuePendingWork = true ,
@@ -171,11 +172,11 @@ public async Task Should_Continue_Parallel_Pending_External_Tool_Requests_After_
171172 var releaseOriginalToolA = new TaskCompletionSource < string > ( TaskCreationOptions . RunContinuationsAsynchronously ) ;
172173 var releaseOriginalToolB = new TaskCompletionSource < string > ( TaskCreationOptions . RunContinuationsAsynchronously ) ;
173174
174- await using var server = Ctx . CreateClient ( useStdio : false ) ;
175+ await using var server = Ctx . CreateClient ( useStdio : false , options : new CopilotClientOptions { TcpConnectionToken = SharedToken } ) ;
175176 await server . StartAsync ( ) ;
176177 var cliUrl = GetCliUrl ( server ) ;
177178
178- using var suspendedClient = Ctx . CreateClient ( options : new CopilotClientOptions { CliUrl = cliUrl } ) ;
179+ using var suspendedClient = Ctx . CreateClient ( options : new CopilotClientOptions { CliUrl = cliUrl , TcpConnectionToken = SharedToken } ) ;
179180 var session1 = await suspendedClient . CreateSessionAsync ( new SessionConfig
180181 {
181182 Tools =
@@ -205,7 +206,7 @@ await Task.WhenAll(
205206
206207 await suspendedClient . ForceStopAsync ( ) ;
207208
208- await using var resumedClient = Ctx . CreateClient ( options : new CopilotClientOptions { CliUrl = cliUrl } ) ;
209+ await using var resumedClient = Ctx . CreateClient ( options : new CopilotClientOptions { CliUrl = cliUrl , TcpConnectionToken = SharedToken } ) ;
209210 var session2 = await resumedClient . ResumeSessionAsync ( sessionId , new ResumeSessionConfig
210211 {
211212 ContinuePendingWork = true ,
@@ -256,12 +257,12 @@ async Task<string> BlockingToolB([Description("Value to look up")] string value)
256257 [ Fact ]
257258 public async Task Should_Resume_Successfully_When_No_Pending_Work_Exists ( )
258259 {
259- await using var server = Ctx . CreateClient ( useStdio : false ) ;
260+ await using var server = Ctx . CreateClient ( useStdio : false , options : new CopilotClientOptions { TcpConnectionToken = SharedToken } ) ;
260261 await server . StartAsync ( ) ;
261262 var cliUrl = GetCliUrl ( server ) ;
262263
263264 string sessionId ;
264- await using ( var firstClient = Ctx . CreateClient ( options : new CopilotClientOptions { CliUrl = cliUrl } ) )
265+ await using ( var firstClient = Ctx . CreateClient ( options : new CopilotClientOptions { CliUrl = cliUrl , TcpConnectionToken = SharedToken } ) )
265266 {
266267 var firstSession = await firstClient . CreateSessionAsync ( new SessionConfig
267268 {
@@ -275,7 +276,7 @@ public async Task Should_Resume_Successfully_When_No_Pending_Work_Exists()
275276 await firstSession . DisposeAsync ( ) ;
276277 }
277278
278- await using var resumedClient = Ctx . CreateClient ( options : new CopilotClientOptions { CliUrl = cliUrl } ) ;
279+ await using var resumedClient = Ctx . CreateClient ( options : new CopilotClientOptions { CliUrl = cliUrl , TcpConnectionToken = SharedToken } ) ;
279280 var resumedSession = await resumedClient . ResumeSessionAsync ( sessionId , new ResumeSessionConfig
280281 {
281282 ContinuePendingWork = true ,
0 commit comments