Skip to content

Python: Fix TypeError in Copilot Studio SK migration samples - #9577

Merged
Eduard van Valkenburg (eavanvalkenburg) merged 1 commit into
microsoft:mainfrom
1aifanatic:contrib/python-copilot-studio-migration-instructions
Oct 22, 2026
Merged

Eduard van Valkenburg (eavanvalkenburg) merged 1 commit into
microsoft:mainfrom
1aifanatic:contrib/python-copilot-studio-migration-instructions

Conversation

@1aifanatic

Copy link
Copy Markdown
Contributor

Motivation & Context

The Agent Framework half of both Semantic Kernel → Agent Framework Copilot Studio migration samples fails on construction:

  • samples/semantic-kernel-migration/copilot_studio/01_basic_copilot_studio_agent.py
  • samples/semantic-kernel-migration/copilot_studio/02_copilot_studio_streaming.py
TypeError: CopilotStudioAgent.__init__() got an unexpected keyword argument 'instructions'

agent_framework.microsoft.CopilotStudioAgent connects to an agent that is already published in Copilot Studio, and its constructor has no instructions parameter (and no **kwargs). The SK half keeps its instructions= argument because that is the SK API being migrated from. semantic-kernel-migration is excluded from the samples type-check sweep (SAMPLE_TYPING_EXCLUDES), so CI did not flag this.

Description & Review Guide

  • What are the major changes? Remove instructions= from the two AF CopilotStudioAgent(...) calls, and add a short comment noting that the agent's instructions are configured in Copilot Studio rather than passed to the wrapper.
  • What is the impact of these changes? Sample only. The AF half now constructs the agent and proceeds to the normal settings/auth path documented in samples/02-agents/providers/copilotstudio/README.md.
  • What do you want reviewers to focus on? The wording of the migration note, since this difference from SK is the useful takeaway for someone migrating.

Verified locally: Pyright on the AF calls no longer reports No parameter named "instructions". With the documented COPILOTSTUDIOAGENT__* variables set (token acquisition stubbed), CopilotStudioAgent(name=...) constructs successfully, and without them it now raises the expected "environment ID is required" ValueError instead of a TypeError. ruff check / ruff format --check pass.

Related Issue

N/A - trivial change: the samples pass a keyword argument the constructor does not accept and fail with TypeError. Removing that argument is the only way to make the AF half run, so the desired result is not in dispute.

AI Assistance

  • No material AI assistance was used.
  • This is an AI-assisted contribution. I reviewed, understood, and verified all submitted content and accept responsibility for it.

AI assistance details: Claude Code helped find the broken samples (by type-checking the excluded migration samples), implement the fix, run the local verification, and draft this description.

Contribution Checklist

  • The code builds clean without any errors or warnings
  • All unit tests pass, and I have added new tests where possible
  • The PR follows the Contribution Guidelines
  • This PR links to an agreed issue with no competing open PR, or the Related Issue section documents a trivial-change or repository-automation exception.
  • This is not a breaking change. If it is a breaking change, add the breaking change label (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.

🤖 Generated with Claude Code

…n samples

agent_framework.microsoft.CopilotStudioAgent connects to an already
published Copilot Studio agent and has no `instructions` parameter, so
the Agent Framework half of both Copilot Studio migration samples raised
TypeError on construction. Remove the argument and note where the
agent's instructions live.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

Both narrowly scoped fixes match the constructor API, and the comments accurately explain instruction configuration.

No open issues 🎉

What changed in this PR

Fixes constructor errors in two Python Copilot Studio migration samples by aligning Agent Framework calls with its supported API.

Changes:

  • Removes unsupported instructions arguments from both Agent Framework calls.
  • Explains that instructions are configured in Copilot Studio; Semantic Kernel calls remain unchanged.
File Description
python/​samples/​semantic-kernel-migration/​copilot_studio/​02_copilot_studio_streaming.py Fixes streaming sample construction and adds configuration guidance.
python/​samples/​semantic-kernel-migration/​copilot_studio/​01_basic_copilot_studio_agent.py Fixes basic sample construction and adds configuration guidance.

Review effort: Balanced

@agent-framework-automation agent-framework-automation Bot added the python Usage: [Issues, PRs], Target: Python label Oct 21, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing the unsupported instructions argument matches the current CopilotStudioAgent constructor, and the migration comments correctly explain that instructions live in the published Copilot Studio agent.

Merged via the queue into microsoft:main with commit c739447 Oct 22, 2026
52 checks passed

This branch was successfully deployed

1 active deployment
github-app-auth — 5237911d Deployed Oct 21, 2026 by 1aifanatic via team_check #7161
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants