Repository navigation
Python: Honor injected Foundry embedding clients without endpoint settings - #9991
Merged
Eduard van Valkenburg (eavanvalkenburg) merged 3 commits intoNov 4, 2026
Conversation
…tings An injected text or image SDK client is the transport for that modality, so construction no longer requires a Foundry endpoint, API key, or credential. Ambient endpoint settings cannot replace or block that client. The other modality is created only when a request needs it and connection settings exist. Co-authored-by: ZedingZhang <me@zedingzhang.com>
ZedingZhang (ZedingZhang)
requested review from
SergeyMenshykh,
Eduard van Valkenburg (eavanvalkenburg) and
Roger Barreto (rogerbarreto)
as code owners
November 2, 2026 18:47
ZedingZhang (ZedingZhang)
temporarily deployed
to
github-app-auth
November 2, 2026 18:47 — with
GitHub Actions
Inactive
ZedingZhang (ZedingZhang)
requested review from
Darren Cohen (dargilco),
Jose Alvarez (jpalvarezl),
sophia-ramsey and
westey (westey-m)
as code owners
November 2, 2026 18:47
2 tasks done
ZedingZhang (ZedingZhang)
temporarily deployed
to
github-app-auth
November 2, 2026 18:48 — with
GitHub Actions
Inactive
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Injected text or image clients still trigger a configuration-conflict ValueError when combined with explicit project settings, violating documented precedence and requiring a fix with regression tests.
1 open issue
What changed in this PR
Updates Python’s Foundry embedding integration so caller-supplied SDK clients can work without separate endpoint or credential settings, addressing #9950.
Changes:
- Accepts injected text or image transports and creates missing clients on demand.
- Derives service URLs from injected clients without substituting ambient endpoints.
- Adds regression tests and usage documentation; resource cleanup remains outside this PR’s scope.
| File | Description |
|---|---|
python/packages/foundry/tests/foundry/test_foundry_embedding_client.py |
Tests injected transports, endpoint precedence, lazy creation, and missing-modality errors. |
python/packages/foundry/README.md |
Documents injected-client configuration and on-demand creation. |
python/packages/foundry/agent_framework_foundry/_embedding_client.py |
Implements injected transport handling, service URL resolution, and deferred client creation. |
Review effort: Balanced
ZedingZhang (ZedingZhang)
temporarily deployed
to
github-app-auth
November 3, 2026 09:44 — with
GitHub Actions
Inactive
ZedingZhang (ZedingZhang)
temporarily deployed
to
github-app-auth
November 3, 2026 10:04 — with
GitHub Actions
Inactive
Eduard van Valkenburg (eavanvalkenburg)
approved these changes
Nov 4, 2026
ZedingZhang (ZedingZhang)
deleted the
cursor/foundry-injected-embedding-client-f900
branch
November 4, 2026 11:02
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Motivation & Context
RawFoundryEmbeddingClientandFoundryEmbeddingClientrejected a caller-supplied embeddings SDK client unless a Foundry project or Models endpoint was also configured. Construction raisedValueError: Either 'project_endpoint', 'project_client', or 'endpoint' is required...even whentext_clientorimage_clientwas already a working transport. AmbientFOUNDRY_MODELS_ENDPOINTcould also become the wrapper service URL while requests still went to the injected client.Callers who already own a configured
EmbeddingsClientorImageEmbeddingsClientshould be able to embed with that client without also supplying an endpoint, API key, credential, dotenv file, or Foundry environment variables.Description & Review Guide
An injected text or image SDK client is the transport for that modality. It takes precedence over constructor connection settings, environment settings, and framework defaults, so those settings are not required and are not used to replace the injected client.
modelandimage_modelkeep the existing explicit-argument, environment, then default resolution.When one modality is injected, the other is created only if a later request needs it and endpoint plus credential settings are available. Client factories are not called for a transport the caller already supplied. A missing modality with insufficient settings raises a focused
ValueErrorat request time, before any partial request is sent.service_url()reads the endpoint stored on an injected Azure AI Inference client when that value is a string. Otherwise it uses an explicitendpointargument, or reports an empty URL instead of substituting an ambient endpoint.Caller-owned client cleanup is unchanged and remains covered by #9627.
text_client/image_clientvalues are sufficient transports inRawFoundryEmbeddingClient(and thereforeFoundryEmbeddingClient). Connection settings are required only when a requested modality still has to be created.endpoint, and ambient Foundry endpoint settings, includingservice_url()when the SDK client does not expose a string endpoint.Related Issue
Fixes #9950. The issue has the
ready-for-implementationlabel; no competing open PR was found before submission.AI Assistance
AI assistance details: Cursor's coding agent assisted with the implementation, regression tests, documentation updates, and this PR description. I reviewed the change and accept responsibility for it.
Contribution Checklist
breaking changelabel (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.