-
Notifications
You must be signed in to change notification settings - Fork 1.1k
.NET: Fix Error 404 Agent Hosted MCP #3678
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
.NET: Fix Error 404 Agent Hosted MCP #3678
Conversation
…nt responses This fix addresses the issue where hosted MCP agents (like AgentWithHostedMCP) fail with "ID cannot be null or empty (Parameter 'id')" error when deployed to Azure AI Foundry. Changes: - Add CreateAgentReference helper method in AzureAIProjectChatClient that defaults empty version to "latest" - Update CreateChatClientAgentOptions to generate a fallback ID from name and version when AgentVersion.Id is null or empty - Add GetAgentVersionResponseJsonWithEmptyVersion and GetAgentResponseJsonWithEmptyVersion test data methods - Add unit tests for empty version handling scenarios Co-authored-by: rogerbarreto <19890735+rogerbarreto@users.noreply.github.com>
Co-authored-by: rogerbarreto <19890735+rogerbarreto@users.noreply.github.com>
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.
Pull request overview
This PR addresses issue #3195 where hosted MCP agents fail with "ID cannot be null or empty" errors. The fix adds fallback logic to handle empty version and ID fields by defaulting to "latest" as the version and generating agent IDs from the agent name and version when the ID is not provided by the server.
Changes:
- Added fallback logic for empty version/ID fields to support hosted MCP agents
- Enhanced test coverage with new test cases for empty version scenarios
- Updated test utilities to simulate hosted agents with empty version fields
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| dotnet/src/Microsoft.Agents.AI.AzureAI/AzureAIProjectChatClient.cs | Added CreateAgentReference helper method to handle empty agent versions by using "latest" as default |
| dotnet/src/Microsoft.Agents.AI.AzureAI/AzureAIProjectChatClientExtensions.cs | Added logic to generate agent IDs from name and version when ID is empty, with "latest" fallback for empty versions |
| dotnet/tests/Microsoft.Agents.AI.AzureAI.UnitTests/TestDataUtil.cs | Added helper methods to generate test data with empty version and ID fields |
| dotnet/tests/Microsoft.Agents.AI.AzureAI.UnitTests/AzureAIProjectChatClientExtensionsTests.cs | Added three new tests and updated FakeAgentClient to support empty version scenarios |
Motivation and Context
AgentWithHostedMCPchat fails:ErrorHTTP 404 (: 404) Resource not found#3195Description
Contribution Checklist