Skip to content

Python: Keep per-call agent settings from replacing defaults - #14834

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

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

Conversation

@Twiink

@Twiink Twiink commented Nov 20, 2026

Copy link
Copy Markdown

Motivation and Context

A per-call model override permanently changes a ChatCompletionAgent's defaults. For example, an agent configured with temperature 0.1 receives a single invocation override of 0.9; the next call without overrides also uses 0.9. Both get_response and invoke reproduce this behavior.

Description

Copy the agent's execution-settings map before merging invocation overrides. Ordinary argument precedence and public signatures stay the same.

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

Related: #14680 handles a business argument named settings; #13598 changes KernelArguments constructors/operators. Neither copies this agent map before updating it.

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 97 tests pass; the full optional-provider matrix was not run.
  • Existing public signatures and normal argument precedence 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:17
Copilot AI balanced review requested due to automatic review settings November 20, 2026 09:17
@Twiink
Twiink deployed to github-app-auth November 20, 2026 09:17 — with GitHub Actions Active

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 were identified for the change that prevents per-call execution settings from overwriting agent defaults.

No open issues 🎉

What changed in this PR

This PR prevents per-call execution settings from permanently replacing ChatCompletionAgent defaults, while preserving public signatures and argument precedence.

Changes:

  • Copies the agent’s execution-settings map before merging invocation overrides.
  • Adds regression and control cases for get_response and invoke, checking that subsequent calls retain defaults and input arguments remain unchanged.
File Description
python/​tests/​unit/​agents/​test_agent_settings_isolation.py Tests settings isolation with and without per-call overrides.
python/​semantic_kernel/​agents/​agent.py Copies the defaults map before applying overrides.

Review effort: Balanced

This branch was successfully deployed

1 active deployment
github-app-auth — 68115ff2 Deployed Nov 20, 2026 by Twiink via add_label #29760
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