Skip to content

Python: Fix Mistral AI seed setting being rejected by the SDK - #14677

Open
alexcastgonz (pcbeingused333) wants to merge 1 commit into
microsoft:mainfrom
pcbeingused333:fix/mistral-seed-random-seed
Open

alexcastgonz (pcbeingused333) wants to merge 1 commit into
microsoft:mainfrom
pcbeingused333:fix/mistral-seed-random-seed

Conversation

@pcbeingused333

Copy link
Copy Markdown
Contributor

ChatRequest.Seed was serialized for Mistral as seed, but Mistral's chat completions take the value as random_seed, so a seed set on the request did not reach the model as the deterministic-sampling seed. random_seed could only be set through ChatRequestVendorMistralExtensions.RandomSeed.

The Mistral request now maps Seed to random_seed and no longer sends seed. ChatRequestVendorMistralExtensions.RandomSeed still takes precedence when set (before, the extension unconditionally overwrote the field, so a null extension value is now ignored instead of clearing the mapped seed).

Added MistralChatSeedTests (no network): Seed becomes random_seed without seed; the extension value wins over Seed; an extensions object without RandomSeed keeps the seed; no seed sends neither field. Three of the four fail on master.

This change was made with the help of an AI assistant (Claude Code); the tests were run locally on net8.0.

Copilot AI balanced review requested due to automatic review settings October 29, 2026 10:15
@semantic-kernel-automation semantic-kernel-automation Bot added the python Pull requests for the Python Semantic Kernel label Oct 29, 2026

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 Mistral seed-parameter mapping change.

No open issues 🎉

What changed in this PR

This PR fixes seed handling in the Python Mistral AI connector by sending the SDK-supported random_seed parameter instead of seed.

Changes:

  • Maps seed to random_seed, preserving an explicitly supplied random_seed.
  • Adds unit tests for seed mapping and explicit-value precedence.
  • Updates streaming and non-streaming service tests to expect random_seed.
File Description
python/​tests/​unit/​connectors/​ai/​mistral_ai/​test_mistralai_request_settings.py Adds seed mapping and precedence tests.
python/​tests/​unit/​connectors/​ai/​mistral_ai/​services/​test_mistralai_chat_completion.py Updates expected SDK arguments for both completion modes.
python/​semantic_kernel/​connectors/​ai/​mistral_ai/​prompt_execution_settings/​mistral_ai_prompt_execution_settings.py Converts seed to random_seed when preparing request settings.

Review effort: Balanced

This branch was successfully deployed

1 active deployment
github-app-auth — b7710095 Deployed Oct 29, 2026 by pcbeingused333 via add_label #29482
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Pull requests for the Python Semantic Kernel

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants