Skip to content

Comments

Python: Fixed SK migration samples#4046

Merged
dmytrostruk merged 3 commits intomicrosoft:mainfrom
dmytrostruk:sample-fixes-5
Feb 18, 2026
Merged

Python: Fixed SK migration samples#4046
dmytrostruk merged 3 commits intomicrosoft:mainfrom
dmytrostruk:sample-fixes-5

Conversation

@dmytrostruk
Copy link
Member

Motivation and Context

  • Fixed incorrect/removed SK method calls (as_agent → create_agent, get_executor_state → get_state, AzureResponsesAgent → OpenAIResponsesAgent, prompt template {{topic}} → {{$topic}}) - Fixed AF API mismatches (HandoffUserInputRequest → HandoffAgentUserRequest, set_coordinator → with_start_agent, ai_model_id → model_id, private import paths → public)
  • Fixed handoff sample: corrected response format, added termination condition, wrapped single targets in lists
  • Removed shadowed Agent imports between SK and AF in shared files
  • Minor fixes: missing self param, session reuse, static method calls, output extraction

Contribution Checklist

  • The code builds clean without any errors or warnings
  • The PR follows the Contribution Guidelines
  • All unit tests pass, and I have added new tests where possible
  • Is this a breaking change? If yes, add "[BREAKING]" prefix to the title of the PR.

@dmytrostruk dmytrostruk self-assigned this Feb 18, 2026
Copilot AI review requested due to automatic review settings February 18, 2026 19:27
Copy link
Contributor

Copilot AI left a 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 fixes incorrect and outdated API calls in Semantic Kernel migration samples to align with recent breaking changes in both Semantic Kernel and Agent Framework APIs. The changes ensure that the migration samples accurately demonstrate the differences between SK and AF patterns.

Changes:

  • Updated SK method names (as_agent → create_agent, get_executor_state → get_state, AzureResponsesAgent → OpenAIResponsesAgent)
  • Fixed AF API parameter names (HandoffUserInputRequest → HandoffAgentUserRequest, set_coordinator → with_start_agent, ai_model_id → model_id)
  • Corrected handoff sample: wrapped single targets in lists, fixed response format to use list[Message], added termination condition
  • Fixed import paths from private (_tools) to public APIs
  • Added missing self parameter to SK method, fixed session reuse pattern, corrected static method calls
  • Updated SK prompt template syntax ({{topic}} → {{$topic}})
  • Improved output extraction logic to handle list[Message] responses
  • Updated dependency markers in uv.lock for Python 3.14 compatibility

Reviewed changes

Copilot reviewed 16 out of 17 changed files in this pull request and generated no comments.

Show a summary per file
File Description
python/uv.lock Updated dependency markers for Python version constraints (< 3.14 for cffi/pythonnet, < 3.11 for exceptiongroup)
python/samples/semantic-kernel-migration/processes/nested_process.py Fixed SK API: get_executor_state → get_state
python/samples/semantic-kernel-migration/processes/fan_out_fan_in_process.py Fixed SK API: get_executor_state → get_state
python/samples/semantic-kernel-migration/orchestrations/magentic.py Removed shadowed Agent import, fixed ai_model_id → model_id, corrected static method call, improved output extraction for list[Message]
python/samples/semantic-kernel-migration/orchestrations/handoff.py Fixed AF handoff API: HandoffUserInputRequest → HandoffAgentUserRequest, set_coordinator → with_start_agent, wrapped single targets in lists, fixed response format to use list[Message], added termination condition
python/samples/semantic-kernel-migration/orchestrations/group_chat.py Removed shadowed Agent import, fixed SK prompt template syntax ({{topic}} → {{$topic}}, {{participants}} → {{$participants}}), added max_rounds parameter
python/samples/semantic-kernel-migration/orchestrations/concurrent_basic.py Fixed return type annotation: list[Agent] → list[ChatCompletionAgent]
python/samples/semantic-kernel-migration/openai_responses/03_responses_agent_structured_output.py Updated to use OpenAIResponsesAgent instead of AzureResponsesAgent, removed credential management
python/samples/semantic-kernel-migration/openai_responses/02_responses_agent_with_tool.py Fixed tool import: _tools → public API, updated to OpenAIResponsesAgent
python/samples/semantic-kernel-migration/openai_responses/01_basic_responses_agent.py Updated to use OpenAIResponsesAgent instead of AzureResponsesAgent
python/samples/semantic-kernel-migration/openai_assistant/03_openai_assistant_function_tool.py Added missing self parameter to method, fixed tool import path, moved plugins parameter to agent instantiation
python/samples/semantic-kernel-migration/openai_assistant/02_openai_assistant_with_code_interpreter.py Fixed SK settings property: chat_deployment_name → chat_model_id
python/samples/semantic-kernel-migration/openai_assistant/01_basic_openai_assistant.py Fixed session reuse pattern to use same session object for follow-up
python/samples/semantic-kernel-migration/chat_completion/02_chat_completion_with_tool.py Fixed tool import: _tools → public API
python/samples/semantic-kernel-migration/azure_ai_agent/03_azure_ai_agent_threads_and_followups.py Fixed SK API: as_agent → create_agent
python/samples/semantic-kernel-migration/azure_ai_agent/02_azure_ai_agent_with_code_interpreter.py Fixed to use static method call for get_code_interpreter_tool
python/samples/semantic-kernel-migration/azure_ai_agent/01_basic_azure_ai_agent.py Fixed SK API: as_agent → create_agent

@dmytrostruk dmytrostruk added this pull request to the merge queue Feb 18, 2026
Merged via the queue into microsoft:main with commit c23bc13 Feb 18, 2026
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants