@@ -87,17 +87,12 @@ public Task<string> GetIndicatorAsync(RoleDialogModel message)
8787 /// </summary>
8888 private sealed class ToolProgressIndicator : IProgress < ProgressNotificationValue >
8989 {
90- private readonly MessageHub < HubObserveData < RoleDialogModel > > _hub ;
91- private readonly string _conversationId ;
90+ private readonly ConversationHub _hub ;
9291 private readonly RoleDialogModel _message ;
9392
94- private ToolProgressIndicator (
95- MessageHub < HubObserveData < RoleDialogModel > > hub ,
96- string conversationId ,
97- RoleDialogModel message )
93+ private ToolProgressIndicator ( ConversationHub hub , RoleDialogModel message )
9894 {
9995 _hub = hub ;
100- _conversationId = conversationId ;
10196 _message = message ;
10297 }
10398
@@ -106,22 +101,16 @@ private ToolProgressIndicator(
106101 /// tool invoked outside one, from a task or a test. Null is the right answer there rather
107102 /// than a reporter that drops everything: it also tells the server not to bother sending.
108103 /// <para>
109- /// The conversation id is read HERE, on the thread that starts the call, and captured.
110- /// <see cref="Report"/> runs on whichever thread the MCP transport is reading on, and
111- /// resolving a scoped service from there to ask again would be a race for a value that
104+ /// The hub is taken HERE, on the thread that starts the call, so it carries the conversation
105+ /// id with it. <see cref="Report"/> runs on whichever thread the MCP transport is reading on,
106+ /// and resolving a scoped service from there to ask again would be a race for a value that
112107 /// cannot change during the call.
113108 /// </para>
114109 /// </summary>
115110 public static ToolProgressIndicator ? For ( IServiceProvider services , RoleDialogModel message )
116111 {
117- var conversationId = services . GetRequiredService < IConversationService > ( ) . ConversationId ;
118- if ( string . IsNullOrWhiteSpace ( conversationId ) )
119- {
120- return null ;
121- }
122-
123- var hub = services . GetRequiredService < MessageHub < HubObserveData < RoleDialogModel > > > ( ) ;
124- return new ToolProgressIndicator ( hub , conversationId , message ) ;
112+ var hub = services . GetHub ( ) ;
113+ return string . IsNullOrWhiteSpace ( hub . ConversationId ) ? null : new ToolProgressIndicator ( hub , message ) ;
125114 }
126115
127116 /// <summary>
@@ -145,7 +134,7 @@ public void Report(ProgressNotificationValue value)
145134
146135 // Cloned: this is pushed to observers that read it, and the function's own message is
147136 // still being used by the call in flight. Its indication is not ours to overwrite.
148- _hub . PushIndication ( RoleDialogModel . From ( _message ) , value . Message , _conversationId ) ;
137+ _hub . PushIndication ( RoleDialogModel . From ( _message ) , value . Message ) ;
149138 }
150139 }
151140
0 commit comments