Skip to content

Python: keep embedding request overrides local to each call - #14856

Open
Twiink wants to merge 1 commit into
microsoft:mainfrom
Twiink:fix/embedding-settings-copy-20261122
Open

Twiink wants to merge 1 commit into
microsoft:mainfrom
Twiink:fix/embedding-settings-copy-20261122

Conversation

@Twiink

@Twiink Twiink commented Nov 22, 2026

Copy link
Copy Markdown

Reusing OpenAIEmbeddingPromptExecutionSettings(dimensions=1536) after a call with dimensions=2 currently sends the next request with 2 dimensions as well. The per-call override writes into the supplied settings object, changing subsequent ingestion requests and potentially producing vectors incompatible with the configured index.

Copy provider-specific embedding settings before assigning model, input and keyword overrides. This also covers Azure embeddings through the shared base class.

Validation:

  • Original source sends dimensions [2, 2]; the regression expects [2, 1536] and checks the supplied settings remain intact.
  • All OpenAI connector unit tests, including Azure embeddings, pass.
  • Ruff check, Ruff format and git diff --check pass.

@Twiink
Twiink requested a review from a team as a code owner November 22, 2026 06:00
Copilot AI balanced review requested due to automatic review settings November 22, 2026 06:00
@Twiink
Twiink temporarily deployed to github-app-auth November 22, 2026 06:00 — 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 remain for the change intended to keep per-call embedding overrides from mutating reusable settings.

No open issues 🎉

What changed in this PR

This PR prevents per-call embedding overrides from mutating reusable OpenAI execution settings. The fix also applies to Azure embeddings through the shared base class.

Changes:

  • Deep-copy supplied provider-specific settings before assigning request fields and overrides.
  • Add a regression test verifying that a dimensions override affects only its call and leaves the original settings unchanged.
File Description
python/​tests/​unit/​connectors/​ai/​open_ai/​services/​test_openai_text_embedding.py Tests call-local dimensions overrides and preservation of shared settings.
python/​semantic_kernel/​connectors/​ai/​open_ai/​services/​open_ai_text_embedding_base.py Copies typed embedding settings before request preparation.

Review effort: Balanced

This branch was previously deployed

1 inactive deployment
github-app-auth — 90724ab7 Deployed Nov 22, 2026 by Twiink via add_label #29792
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