semantic-kernel icon indicating copy to clipboard operation
semantic-kernel copied to clipboard

Python: semantic-kernel v1.35.2 cannot import agents if running azure-ai-agents==1.1.0

Open PranshuBansalDev opened this issue 3 months ago • 4 comments

Describe the bug Cannot import AzureAIAgent from semantic_kernel.agents

>>> from semantic_kernel.agents import AzureAIAgent
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/venv/lib/python3.12/site-packages/semantic_kernel/agents/__init__.py", line 58, in __getattr__
    module = importlib.import_module(submod_name, package=__name__)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/importlib/__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/venv/lib/python3.12/site-packages/semantic_kernel/agents/azure_ai/azure_ai_agent.py", line 39, in <module>
    from semantic_kernel.agents.azure_ai.agent_thread_actions import AgentThreadActions
  File "/home/venv/lib/python3.12/site-packages/semantic_kernel/agents/azure_ai/agent_thread_actions.py", line 8, in <module>
    from azure.ai.agents.models import (
ImportError: cannot import name 'RequiredMcpToolCall' from 'azure.ai.agents.models' (/home/venv/lib/python3.12/site-packages/azure/ai/agents/models/__init__.py). Did you mean: 'RequiredToolCall'?
>>>
KeyboardInterrupt
>>>

To Reproduce Steps to reproduce the behavior:

  1. python3 -m venv venv
  2. source venv/bin/activate
  3. pip install azure-ai-agents
  4. pip install semantic-kernel
  5. python
  6. from semantic_kernel.agents import AzureAIAgent

Expected behavior Expect this import to work

Screenshots If applicable, add screenshots to help explain your problem.

Platform

  • Language: Python
  • Source: semantic-kernel==1.35.2, azure-ai-agents=1.1.0
  • AI model: [e.g. OpenAI:GPT-4o-mini(2024-07-18)]
  • IDE: terminal
  • OS: wsl / Ubuntu 24.04

Additional context If you reverse the install order (semantic-kernel first) its fine, but I don't think SK should take a dependency on pre-release packages, as it can cause issues if package installation is done out of order

PranshuBansalDev avatar Aug 08 '25 21:08 PranshuBansalDev

I am able to reproduce this issue on azure-ai-agents==1.1.0 but not azure-ai-agents==1.2.0b1 and azure-ai-agents==1.1.0b4.

May be worth reaching out to the Azure AI SDK team.

A temporary solution for us would be to exclude 1.1.0. @moonbox3 and @eavanvalkenburg what do you two think?

TaoChenOSU avatar Aug 08 '25 22:08 TaoChenOSU

To be able to use the AzureSDK's latest features, one has to install the latest packages - even beta - because as you can see, without them, there currently is no MCP tool support.

Our pyproject.toml specifies that the min version for SK 1.35.2 is 1.1.0b4.

https://github.com/microsoft/semantic-kernel/blob/d4e02783307da0159a7278e37824909ebb58b260/python/pyproject.toml#L28

moonbox3 avatar Aug 11 '25 01:08 moonbox3

@moonbox3 - I'd recommend examining the repro steps, the issue here isn't simply a version mismatch

It's that by taking a dependency on a pre-release version, if customers install the tools out of order (e.g. starting with azure-ai-agents), the semantic-kernel install breaks on import of AIAgent, which is a really really bad experience.

This is essentially the current customer experience:

  1. install azure-ai-agents
  2. install sk
  3. import ai agents from sk
  4. see it breaks
  5. Check for reports on this issue, find none (now find this one)
  6. find the minimum versions needed
  7. check here https://pypi.org/project/azure-ai-projects/#history
  8. notice that 1.1.0b4 is a pre-release version
  9. realize you have to pin all your azure-ai-agent installs to pre-release versions to fix the issue
  10. Give up and just downgrade sk to previous release

I've spoken with Tao about this offline, but I'd recommend fixing this, perhaps by excluding the 1.1.0 as an acceptable version for azure-ai-agents

PranshuBansalDev avatar Aug 11 '25 15:08 PranshuBansalDev

This issue is stale because it has been open for 90 days with no activity.

github-actions[bot] avatar Nov 10 '25 02:11 github-actions[bot]