Repository navigation
Description
Observed Behavior
RawFoundryEmbeddingClient and FoundryEmbeddingClient do not treat injected EmbeddingsClient / ImageEmbeddingsClient instances as complete transport configuration.
In python/packages/foundry/agent_framework_foundry/_embedding_client.py, the constructor loads Foundry settings and then requires project_endpoint, project_client, or endpoint before it can use caller-supplied text_client or image_client values. A working caller-owned text client therefore still fails construction when no Foundry endpoint is present in constructor arguments or the environment.
This also lets ambient FOUNDRY_MODELS_ENDPOINT select the wrapper's service URL even though the injected SDK client may target a different endpoint.
Expected Behavior
An injected embedding SDK client should take precedence over constructor connection settings, environment settings, and framework defaults. The caller should be able to use a preconfigured text client for text embeddings without also supplying an endpoint, API key, credential, or environment configuration.
Wrapper-owned request configuration such as model / image_model should keep its own explicit-argument, environment, then default resolution. Construction should raise only when an operation needs a transport that cannot be obtained from an injected client or any applicable initialization settings.
Steps to Reproduce
- Clear
FOUNDRY_PROJECT_ENDPOINTandFOUNDRY_MODELS_ENDPOINT. - Create a preconfigured Foundry
EmbeddingsClient(or a mock with the same interface). - Pass it as
text_clientwith an explicit embedding model. - Observe that construction raises before the injected client can be used.
Minimal Reproduction
from unittest.mock import MagicMock
from agent_framework_foundry import RawFoundryEmbeddingClient
text_client = MagicMock()
RawFoundryEmbeddingClient(
model="text-embedding-model",
text_client=text_client,
)Error Messages and Stack Traces
ValueError: Either 'project_endpoint', 'project_client', or 'endpoint' is required. Set a Foundry project endpoint via 'FOUNDRY_PROJECT_ENDPOINT' or a Foundry Models endpoint via 'FOUNDRY_MODELS_ENDPOINT'.
Package Versions
agent-framework-foundry: 1.16.0; agent-framework-core: 1.24.0; main at 93c346f
Python Version
Python 3.13.1
Operating System
macOS
Regression
Unknown
Additional Context
Affected constructors:
RawFoundryEmbeddingClient.__init__FoundryEmbeddingClient.__init__through the raw base constructor
Compatibility impact: callers that currently receive an early ValueError for injected-client-only configuration would instead get a usable client. service_url() may need to derive the endpoint from the injected SDK client when possible, or report an unknown endpoint without replacing the transport.
Focused acceptance tests:
- A text-only injected client works with no endpoint, API key, credential,
.envfile, or Foundry environment variables. - An image-only injected client works under the same conditions.
- Unrelated or invalid endpoint environment values do not replace or block an injected client.
- Client factories are not called for already supplied transports.
- A focused error is raised only when a requested text/image operation has neither an injected transport nor enough settings to create one.
Caller-owned client cleanup is a separate released-package lifecycle contract already tracked by #9627.
AI assistance: I used an AI coding assistant to audit the source and draft this report. I reproduced the behavior locally against the cited main commit.
Acknowledgements
- I searched existing issues and did not find a duplicate.
- I personally verified this behavior and the reproduction details are authentic.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
ZedingZhang commentedon Nov 2, 2026
I'll take this one, implementing so injected Foundry embedding SDK clients (
text_client/image_client) work without requiringproject_endpoint/project_client/endpoint(or ambient Foundry env vars), per the acceptance cases in the issue.