Skip to content

Python: Isolate agent default function choices from shared settings - #14835

Open
Twiink wants to merge 1 commit into
microsoft:mainfrom
Twiink:fix/agent-function-choice-isolation
Open

Twiink wants to merge 1 commit into
microsoft:mainfrom
Twiink:fix/agent-function-choice-isolation

Conversation

@Twiink

@Twiink Twiink commented Nov 20, 2026

Copy link
Copy Markdown

Motivation and Context

When agents share model settings that leave function_choice_behavior unset, the first agent writes its default into those settings. A second agent configured with NoneInvoke then receives the first agent's Auto choice instead. get_response, invoke and invoke_stream all reproduce this.

Description

Copy the selected settings before supplying an agent's fallback function choice. Explicit choices remain authoritative; the caller's settings remain reusable.

Validation: three regression cases fail on unchanged main and three explicit-choice controls pass. The fix passes 99 related agent/channel/argument tests, Ruff 0.9.6 lint/format, Bandit, wheel build and six public consumers using the installed wheel. The full optional-provider matrix was not run.

Related #14752 changes dictionary defaults in FunctionChoiceBehavior.from_dict, and #14014 forwards behavior to tool invocation. Their current diffs do not change these fallback assignments.

Contribution Checklist

  • The code builds clean without any errors or warnings
  • The PR follows the SK Contribution Guidelines; changed-file formatting and lint checks pass
  • All unit tests pass, and I have added new tests where possible. The related 99 tests pass; the full optional-provider matrix was not run.
  • Existing public signatures and explicit model choices are preserved

Prepared and verified with OpenAI Codex assistance.

@Twiink
Twiink requested a review from a team as a code owner November 20, 2026 09:32
Copilot AI balanced review requested due to automatic review settings November 20, 2026 09:32
@Twiink
Twiink temporarily deployed to github-app-auth November 20, 2026 09:32 — with GitHub Actions Inactive

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

No active review issues are reported for the change isolating agent defaults from shared execution settings.

No open issues 🎉

What changed in this PR

This PR prevents ChatCompletionAgent defaults from modifying shared execution settings, so agents can reuse those settings while retaining their own fallback function choices.

Changes:

  • Copy settings before applying a fallback function choice in streaming and non-streaming invocation paths.
  • Add regression tests across get_response, invoke, and invoke_stream, including controls confirming that explicit choices remain authoritative.
File Description
python/​tests/​unit/​agents/​chat_completion/​test_function_choice_isolation.py Tests shared-settings isolation and preservation of explicit function choices.
python/​semantic_kernel/​agents/​chat_completion/​chat_completion_agent.py Copies settings before assigning the agent’s default function choice.

Review effort: Balanced

This branch was previously deployed

1 inactive deployment
github-app-auth — 594df47b Deployed Nov 20, 2026 by Twiink via add_label #29761
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants