-
Notifications
You must be signed in to change notification settings - Fork 8
Fix agentId parameter in foundry sdk #139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -92,9 +92,19 @@ public void AddToolServersToAgent( | |||||
| } | ||||||
| } | ||||||
|
|
||||||
| /// <inheritdoc /> | ||||||
| /// <summary> | ||||||
| /// Add new MCP servers to the agent by updating the PersistentAgentsClient asynchronously. | ||||||
| /// </summary> | ||||||
| /// <param name="agentClient">PersistentAgentsClient instance for the agent.</param> | ||||||
| /// <param name="agentInstanceId">The ID of the agent instance.</param> | ||||||
| /// <param name="userAuthorization">User authorization information.</param> | ||||||
| /// <param name="authHandlerName">The name of the authentication handler.</param> | ||||||
| /// <param name="turnContext">Turn context for the current request.</param> | ||||||
| /// <param name="authToken">Authentication token for MCP server access.</param> | ||||||
| /// <exception cref="ArgumentNullException"></exception> | ||||||
| public async Task AddToolServersToAgentAsync( | ||||||
| PersistentAgentsClient agentClient, | ||||||
| string agentInstanceId, | ||||||
| UserAuthorization userAuthorization, | ||||||
| string authHandlerName, | ||||||
| ITurnContext turnContext, | ||||||
|
|
@@ -110,23 +120,21 @@ public async Task AddToolServersToAgentAsync( | |||||
| authToken = await AgenticAuthenticationService.GetAgenticUserTokenAsync(userAuthorization, authHandlerName, turnContext, _configuration).ConfigureAwait(false); | ||||||
| } | ||||||
|
|
||||||
| var agenticAppId = turnContext.Activity.Recipient.AgenticAppId; | ||||||
|
|
||||||
| try | ||||||
| { | ||||||
| // Perform the (potentially async) work in a dedicated task to keep this synchronous signature. | ||||||
|
||||||
| // Perform the (potentially async) work in a dedicated task to keep this synchronous signature. |
Copilot
AI
Dec 12, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using GetAwaiter().GetResult() in an async method defeats the purpose of async/await and can lead to potential deadlocks. Since this method is already async, consider using await instead: var (toolDefinitions, toolResources) = await GetMcpToolDefinitionsAndResourcesAsync(agentInstanceId, authToken ?? string.Empty, turnContext).ConfigureAwait(false);
| var (toolDefinitions, toolResources) = GetMcpToolDefinitionsAndResourcesAsync(agentInstanceId, authToken ?? string.Empty, turnContext).GetAwaiter().GetResult(); | |
| var (toolDefinitions, toolResources) = await GetMcpToolDefinitionsAndResourcesAsync(agentInstanceId, authToken ?? string.Empty, turnContext).ConfigureAwait(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have both TurnContext and auth token here, you should use this instead of adding another parameter and letting the caller handle it: