Enhance ResearcherAgent to handle Microsoft Learn MCP server unavaila… - #27
Merged
Merged
Conversation
…bility gracefully and simplify logging of tool invocations.
There was a problem hiding this comment.
🟡 Changes recommended
The new startup MCP client flow introduces a likely resource-lifetime/disposal issue and overly broad exception handling that can hide real startup failures.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR improves the robustness of the research toolchain by making Microsoft Learn MCP integration optional at startup (falling back to Tavily-only when unavailable) and by simplifying/safer logging around tool invocations in ResearcherAgent.
Changes:
- Simplify
ResearcherAgenttool-invocation logging to avoid emitting tool arguments. - Wrap Microsoft Learn MCP client initialization/tool discovery in a startup try/catch and continue without it on failure.
- Add a dedicated startup logger for clearer warning output during initialization.
File summaries
| File | Description |
|---|---|
| ResearcherAgent.cs | Reduces tool invocation log detail to just the tool name (no arguments). |
| Program.cs | Makes Microsoft Learn MCP tool discovery best-effort and logs a warning when unavailable. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+127
to
+138
| List<AIFunction> researcherTools = [tavilyTool]; | ||
| try | ||
| { | ||
| McpClient microsoftLearnMcp = await McpClient.CreateAsync( | ||
| new HttpClientTransport(new HttpClientTransportOptions | ||
| { | ||
| Endpoint = new Uri("https://learn.microsoft.com/api/mcp"), | ||
| Name = "microsoft-learn", | ||
| })); | ||
| IList<McpClientTool> microsoftLearnTools = await microsoftLearnMcp.ListToolsAsync(); | ||
| researcherTools.AddRange(microsoftLearnTools); | ||
| } |
Comment on lines
+139
to
+142
| catch (Exception ex) | ||
| { | ||
| startupLogger.LogWarning(ex, "Microsoft Learn MCP server unavailable; continuing with Tavily-only research tools."); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…bility gracefully and simplify logging of tool invocations.