Microsoft Agent Framework: Copilot Studio Agent Provider Class Does Not Exist

Michael Zayed 0 Reputation points

Hi, I am currently exploring the Microsoft Agent Framework to develop an internal tool at the company I work for. I am trying to use Copilot Studio as the Provider for the Agent, but both the C# and Python versions of this class do not work. The required packages install correctly with dotnet and pip, but whenever I try to call the constructor, terminal says it does not exist.

Here is the error I got in the terminal in Python after downloading the package and including all necessary imports:

ModuleNotFoundError: The package agent-framework-copilotstudio is required to use CopilotStudioAgent. Please use pip install agent-framework-copilotstudio, or update your requirements.txt or pyproject.toml file.

I have also included the link to the documentation on the Microsoft Agent Framework Website. Thanks for your help, and I hope to hear from you soon.

Link: https://learn.microsoft.com/en-us/agent-framework/agents/providers/copilot-studio?pivots=programming-language-python

  1. Anshika Varshney 13,405 Reputation points β€’ Microsoft External Staff β€’ Moderator

    Hello @Michael Zayed

    Did you get any chance to review the response.

    Thankyou!

  2. Michael Zayed 0 Reputation points

    Hi @Anshika Varshney

    Yes, I did have the chance to take a look at your feedback, and I did get it to work. Thank you!

  3. Anshika Varshney 13,405 Reputation points β€’ Microsoft External Staff β€’ Moderator

    Hello @Michael Zayed

    Thank you for sharing the update I appreciate you taking the time to confirm the resolution!

    Since I’ve converted comment into an answer, could you please take a moment to mark it as Accepted?

    This helps others in the community with the same question find the solution more easily.

    Thankyou!


Sign in to comment

2 answers

  1. Anshika Varshney 13,405 Reputation points β€’ Microsoft External Staff β€’ Moderator

    Hello @Michael Zayed

    Thanks for sharing the details, this usually happens when the provider package is installed but not correctly recognized by the runtime or version.

    Here are a few things to check:

    1. Make sure the package is installed in the correct environment For Python:
    • Run python -m pip install --upgrade pip
    • Then python -m pip install --pre agent-framework-copilotstudio
    • Verify using pip show agent-framework-copilotstudio

    For .NET:

    • Add the package using: dotnet add package Microsoft.Agents.AI.CopilotStudio --prerelease
    • Verify with dotnet list package
    1. Confirm the correct import/namespace The class will only be available if the correct module path is used. For example:
    • Python: from agent_framework.providers.copilotstudio import CopilotStudioAgent
    • C#: using Microsoft.Agents.AI.CopilotStudio;
    1. Check preview/version compatibility This provider is still in preview, so:
    • Make sure you are using the latest prerelease version
    • Ensure Python/.NET SDK versions are compatible
    • Restart your environment after installation (this is often required)
    1. Verify package actually contains the class Sometimes older versions of the package do not include this provider yet. If needed, reinstall or upgrade to the latest prerelease version.

    If you’re still seeing the issue, it would help to share:

    • Your Python version and pip list output
    • The exact import statement you are using
    • .NET SDK version (dotnet --info) and package list
    • Full error message

    This will help narrow down whether it’s an environment issue or a version mismatch.

    Hope this helps. Do let me know if you have any further queries.

    Thankyou!

    0 comments No comments

    Sign in to comment
  2. AI answer

    In Python, CopilotStudioAgent is provided by the separate agent-framework-copilotstudio package and is imported from agent_framework.microsoft, not directly from agent_framework.

    To resolve the ModuleNotFoundError:

    1. Install the Copilot Studio provider package (note the --pre flag):
       pip install agent-framework-copilotstudio --pre
      
    2. Ensure the code imports the correct type from the correct module:
       import asyncio
       from agent_framework.microsoft import CopilotStudioAgent
       
       async def main():
       agent = CopilotStudioAgent()
       result = await agent.run("What are our company policies on remote work?")
       print(result)
       
       asyncio.run(main())
      
    3. Set the required environment variables so CopilotStudioAgent can read its configuration:
       set COPILOTSTUDIOAGENT__ENVIRONMENTID="<your-environment-id>"
       set COPILOTSTUDIOAGENT__SCHEMANAME="<your-agent-schema-name>"
       set COPILOTSTUDIOAGENT__AGENTAPPID="<your-client-id>"
       set COPILOTSTUDIOAGENT__TENANTID="<your-tenant-id>"
      
      (Use the appropriate syntax for the shell/OS in use.)

    If the error still appears after installing with --pre, verify that the environment where the script runs is the same one where the package was installed (for example, correct virtual environment or interpreter) and that there is no conflicting agent_framework installation without the Copilot Studio provider.

    For .NET, Copilot Studio is exposed as a provider within the Agent Framework; ensure the correct provider package is referenced and that the project targets the version of the Agent Framework that includes the Copilot Studio provider listed under the Providers Overview.


    References:

    AI-generated content may be incorrect. Read our transparency notes for more information.
Sign in to answer

Your answer