Skip to content

Python: [Bug]: Foundry embedding clients require endpoint settings even when SDK clients are injected #9950

Closed

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

  1. Clear FOUNDRY_PROJECT_ENDPOINT and FOUNDRY_MODELS_ENDPOINT.
  2. Create a preconfigured Foundry EmbeddingsClient (or a mock with the same interface).
  3. Pass it as text_client with an explicit embedding model.
  4. 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, .env file, 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.

Activity

  1. ZedingZhang commented on Nov 2, 2026

    @ZedingZhang
    Contributor

    I'll take this one, implementing so injected Foundry embedding SDK clients (text_client / image_client) work without requiring project_endpoint / project_client / endpoint (or ambient Foundry env vars), per the acceptance cases in the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    pythonUsage: [Issues, PRs], Target: Pythonready-for-implementationMaintainers agree the problem and direction are ready for implementation.

    Type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions