Skip to content

feat(models): adding python support for Azure foundry models (OpenAI + Anthropic types) - #2512

Open
marosset wants to merge 2 commits into
kagent-dev:mainfrom
marosset:foundry-python
Open

feat(models): adding python support for Azure foundry models (OpenAI + Anthropic types)#2512
marosset wants to merge 2 commits into
kagent-dev:mainfrom
marosset:foundry-python

Conversation

@marosset

Copy link
Copy Markdown
Contributor

Part of #2072

#2091 added foundry support for the Go runtime. This PR does the same for python.

As part of this change the AzureOpenAI model auth is moved to use unified Azure auth mechanisms (including API_KEY-less / workload identity support)

… anthropic types)

Signed-off-by: Mark Rossetti <marosset@microsoft.com>
@marosset
marosset requested a review from a team as a code owner August 20, 2026 18:25
Copilot AI lite review requested due to automatic review settings August 20, 2026 18:25
@marosset marosset changed the title feat(models) adding python support for Azure foundry models (OpenAI + Anthropic types) feat(models): adding python support for Azure foundry models (OpenAI + Anthropic types) Aug 20, 2026
@github-actions github-actions Bot added the enhancement New feature or request label Aug 20, 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.

Pull request overview

Adds Azure AI Foundry provider support to the Python ADK runtime, including OpenAI-compatible chat/embeddings and an Anthropic-format client path, while unifying Azure authentication to support API-key-less Azure Workload Identity via azure-identity.

Changes:

  • Introduces shared Azure helpers (_azure.py) for endpoint/deployment resolution, auth header sanitization, and implicit Workload Identity token providers.
  • Adds Foundry support to OpenAI chat and embeddings flows, plus Foundry Anthropic client support for Claude-on-Foundry.
  • Expands unit test coverage for Azure OpenAI + Foundry auth modes (API key, passthrough, Workload Identity) and wiring.

Reviewed changes

Copilot reviewed 11 out of 12 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
python/uv.lock Adds Azure Identity dependency closure (azure-core, azure-identity, msal, msal-extensions).
python/packages/kagent-adk/pyproject.toml Declares azure-identity as a runtime dependency for Workload Identity support.
python/packages/kagent-adk/src/kagent/adk/models/_azure.py New shared Azure auth/config helpers and client builders for OpenAI + Anthropic surfaces.
python/packages/kagent-adk/src/kagent/adk/models/_openai.py Refactors Azure OpenAI client creation to use unified Azure auth; adds Foundry OpenAI model support.
python/packages/kagent-adk/src/kagent/adk/models/_embedding.py Adds Foundry embeddings provider path and unifies Azure embeddings client construction.
python/packages/kagent-adk/src/kagent/adk/models/_anthropic.py Adds Foundry Anthropic implementation and improves passthrough client caching behavior.
python/packages/kagent-adk/src/kagent/adk/models/init.py Exposes Foundry OpenAI model via public kagent.adk.models exports.
python/packages/kagent-adk/src/kagent/adk/types.py Adds Foundry model config and wires provider dispatch (openai vs anthropic format).
python/packages/kagent-adk/tests/unittests/test_embedding.py Adds Foundry embeddings tests for API key + Workload Identity + passthrough semantics.
python/packages/kagent-adk/tests/unittests/models/test_openai.py Updates patch targets for Azure client construction; adds an import.
python/packages/kagent-adk/tests/unittests/models/test_azure.py New tests validating Azure OpenAI/Foundry auth behavior and header sanitization.
python/packages/kagent-adk/tests/unittests/models/test_anthropic.py Adds Foundry Anthropic tests (format dispatch, auth modes, request headers).

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread python/packages/kagent-adk/src/kagent/adk/models/__init__.py
Comment thread python/packages/kagent-adk/tests/unittests/models/test_openai.py Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Mark Rossetti <marosset@microsoft.com>
response = await client.embeddings.create(
model=self.config.model,
input=texts,
dimensions=self.TARGET_DIMENSION,

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.

forces 768 dims here too. same bug as _embed_openai above it, a fix for that one is already open in #2542. providers with other dims will fail here as well.

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

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants