Skip to content

azure-ai-agents: MCP usage errors with Azure AI Foundry #42428

@jacobreesmontgomery

Description

@jacobreesmontgomery
  • Packages:
    • azure-ai-projects: 1.0.0b10
    • azure-ai-agents: 1.2.0b1
  • Operating System: macOS Sequoia 15.5
  • Python Version: 3.11.8

Describe the bug
I've been having issues using the MCP integrations with Azure AI Foundry agents. Specifically, there are two things:

  1. An AssertionError is frequently occurring. It's happened for both GitMCP and Tavily's MCP servers. I have yet to try more MCP servers, but I suspect I'll continue to see these errors coming up. See the error below.
  2. I'm seeing repeated failures to invoke the tools provided to the agent for these MCP servers, resulting in unsatisfactory answers. See below for the error.
    • Perhaps I need to provide more specific instructions to the agent to guide it towards invoking the tools provided? I would think the agent would be smart enough to know as is without more specific prompting.

Error to problem 1

The result with the error:

{
  "data": {
    "response": "I encountered an issue while trying to get the current weather information for Seattle. You can check a reliable weather website or app for real-time updates. Alternatively, if you need general information about Seattle's climate or typical weather patterns, feel free to ask!"
  },
  "meta": {
    "run_steps": [
      {
        "id": "step_hgixrj0R0tORvoMZpTkf14cN",
        "object": "thread.run.step",
        "created_at": 1754658900,
        "run_id": "run_cT1NcPI13R3b88JJA9oDq179",
        "assistant_id": "asst_GyjPbDs3XfMbSrv0VehZmcFv",
        "thread_id": "thread_jlp4vdxxi3HlI7F5E67A6jEC",
        "type": "message_creation",
        "status": "completed",
        "cancelled_at": null,
        "completed_at": 1754658901,
        "expires_at": null,
        "failed_at": null,
        "last_error": null,
        "step_details": {
          "type": "message_creation",
          "message_creation": {
            "message_id": "msg_q8TpSGSexr47v7Pb0nImYnbc"
          }
        },
        "usage": {
          "prompt_tokens": 152,
          "completion_tokens": 52,
          "total_tokens": 204,
          "prompt_token_details": {
            "cached_tokens": 0
          }
        }
      },
      {
        "id": "step_ovu486RNvTcTKZ0zIBUmEB72",
        "object": "thread.run.step",
        "created_at": 1754658900,
        "run_id": "run_cT1NcPI13R3b88JJA9oDq179",
        "assistant_id": "asst_GyjPbDs3XfMbSrv0VehZmcFv",
        "thread_id": "thread_jlp4vdxxi3HlI7F5E67A6jEC",
        "type": "tool_calls",
        "status": "completed",
        "cancelled_at": null,
        "completed_at": 1754658900,
        "expires_at": null,
        "failed_at": null,
        "last_error": null,
        "step_details": {
          "type": "tool_calls",
          "tool_calls": [
            {
              "id": "call_UWl9nlG2w8akjCWKLMpgdeKi",
              "type": "mcp",
              "arguments": "{\"location\":\"Seattle, WA\"}",
              "name": "weather",
              "server_label": "tavily",
              "output": "content_type='system_error' name='AssertionError' text=\"Encountered exception: <class 'AssertionError'>.\""
            }
          ]
        },
        "usage": {
          "prompt_tokens": 106,
          "completion_tokens": 19,
          "total_tokens": 125,
          "prompt_token_details": {
            "cached_tokens": 0
          }
        }
      }
    ]
  }
}

Error to problem 2

{
  "data": {
    "response": "I currently don't have real-time capabilities to check the latest weather. However, you can easily find the current weather in Seattle by checking a weather website or app like Weather.com, the Weather Channel, or a local news website. Alternatively, you can use a digital assistant on your phone or smart device to get the latest weather update."
  },
  "meta": {
    "run_steps": [
      {
        "id": "step_47k5HIxdJe4D1T02IvGfzqZ5",
        "object": "thread.run.step",
        "created_at": 1754659678,
        "run_id": "run_HF0DgO0m9n8PhVZyYqMKz7JL",
        "assistant_id": "asst_xOCNz0JcZ2yMbzbDDZ96FIee",
        "thread_id": "thread_uKI5zjsP5xAIhXfJ9rEO0x43",
        "type": "message_creation",
        "status": "completed",
        "cancelled_at": null,
        "completed_at": 1754659679,
        "expires_at": null,
        "failed_at": null,
        "last_error": null,
        "step_details": {
          "type": "message_creation",
          "message_creation": {
            "message_id": "msg_ThsZroUC9qje77hFJuPTuSR8"
          }
        },
        "usage": {
          "prompt_tokens": 106,
          "completion_tokens": 68,
          "total_tokens": 174,
          "prompt_token_details": {
            "cached_tokens": 0
          }
        }
      }
    ]
  }
}

To Reproduce
Steps to reproduce the behavior:

  1. Create a Foundry agent integrated with the Tavily MCP server:
  2. Ask the agent something like "What is the weather in Seattle today?"
  3. Repeat the above two steps a handful of times to see both problems outlined above.

Expected behavior
I would expect two things:

  1. No assertion errors when the tavily-search tool is invoked.
  2. The tool always being invoked (although I understand there's a level of non-determinism to agents).

Screenshots
N/A

Additional context

  • The agent is using model gpt-4o with a provided temperature of 0.7.
  • The agent's instructions are very basic: You are a helpful assistant. When appropriate, use the available tools to help answer the user's query..

Metadata

Metadata

Assignees

Labels

AIAI AgentsService AttentionWorkflow: This issue is responsible by Azure service team.customer-reportedIssues that are reported by GitHub users external to the Azure organization.issue-addressedWorkflow: The Azure SDK team believes it to be addressed and ready to close.questionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions