Skip to content

Python: [BREAKING] Migrate Foundry Local integration to SDK 2.3.1 - #9322

Merged
Eduard van Valkenburg (eavanvalkenburg) merged 29 commits into
microsoft:mainfrom
bmehta001:fix-foundry-local-sdk-compatibility
Nov 4, 2026
Merged

Eduard van Valkenburg (eavanvalkenburg) merged 29 commits into
microsoft:mainfrom
bmehta001:fix-foundry-local-sdk-compatibility

Conversation

@bmehta001

@bmehta001 bmehta001 commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Motivation & Context

The Foundry Local integration still uses SDK 0.5.1. This updates it to work with SDK 2.3.1.

Description & Review Guide

  • What are the major changes? Updates SDK setup and model loading for SDK 2.3.1, adds support for SDK-registered local models, and keeps the existing chat, streaming, and tool support.
  • What is the impact of these changes? Requires Python 3.11-3.14 and SDK 2.3.1 or later, below 3.0. Older SDK versions are no longer supported. prepare_model=False still loads the configured model on the first request, including streaming; manual loading is not required.
  • What do you want reviewers to focus on? Model setup, loading on first use, and cleanup when setup fails.

Image support has not been verified. Audio and embeddings are outside this PR.

Related Issue

Fixes #9321.

Original report: microsoft/homebrew-foundrylocal#31.

Maintainer agreement and human review are pending.

AI Assistance

  • No material AI assistance was used.
  • This is an AI-assisted contribution. Human review is pending.

AI assistance details: GitHub Copilot helped with the code, tests, documentation, and this description.

Contribution Checklist

  • The code builds clean without any errors or warnings
  • All unit tests pass, and I have added new tests where possible
  • The PR follows the Contribution Guidelines
  • This PR links to an agreed issue with no competing open PR, or the Related Issue section documents a trivial-change or repository-automation exception.
  • This is not a breaking change. If it is a breaking change, add the breaking change label (or add "[BREAKING]" to the title prefix, before or after any language prefix) -- a workflow keeps the label and title prefix in sync automatically.

Use the in-process SDK singleton and catalog model APIs with the existing OpenAI transport. Require Python 3.11 and document the breaking migration.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: d8ebdb3c-28b8-4fa1-830d-3fa7d6333d9e
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: d8ebdb3c-28b8-4fa1-830d-3fa7d6333d9e
Copilot AI balanced review requested due to automatic review settings October 12, 2026 22:36
@agent-framework-automation agent-framework-automation Bot added documentation Usage: [Issues, PRs], Target: documentation in the code base and learn docs python Usage: [Issues, PRs], Target: Python breaking change Usage: [PRs], Target: all PRs that introduce changes that are not backward compatible labels Oct 12, 2026
Follow the existing OpenAI test pattern so transport coverage works with both OpenAI 2.x and locked OpenAI 3.x/httpx2.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: d8ebdb3c-28b8-4fa1-830d-3fa7d6333d9e

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.

🟡 Changes recommended

Python 3.15 compatibility declarations and CI gating are inconsistent, and singleton construction has a concurrency race.

5 open findings
What changed in this PR

Migrates the Python Foundry Local integration to SDK 2.1, addressing #9321 while retaining Agent Framework’s OpenAI transport.

Changes:

  • Adopts the SDK singleton, catalog/model lifecycle, and built-in web service.
  • Raises support to Python 3.11+ and updates dependencies and CI.
  • Expands migration documentation and regression tests.
File Description
.github/​workflows/​python-tests.yml Updates Python-version exclusions.
python/​packages/​core/​pyproject.toml Gates the Foundry Local extra.
python/​packages/​foundry_local/​AGENTS.md Updates package guidance.
python/​packages/​foundry_local/​README.md Documents usage and migration.
python/​packages/​foundry_local/​agent_framework_foundry_local/​_foundry_local_client.py Implements SDK 2.1 integration.
python/​packages/​foundry_local/​pyproject.toml Updates Python and SDK requirements.
python/​packages/​foundry_local/​tests/​conftest.py Adds SDK-aware fixtures.
python/​packages/​foundry_local/​tests/​test_foundry_local_client.py Expands lifecycle and transport tests.
python/​samples/​02-agents/​providers/​foundry/​foundry_local_agent.py Updates sample APIs and cleanup.
python/​uv.lock Resolves SDK 2.1 dependencies.

🧠 Review effort: Balanced


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

Comment thread .github/workflows/python-tests.yml Resolved
Comment thread python/packages/core/pyproject.toml Resolved
Comment thread python/packages/foundry_local/README.md Resolved
SDK 2.1 pins ONNX Runtime 1.30.0, which has no Python 3.15 wheels. Exclude Foundry Local from the 3.15 workspace job and align package and extra metadata with Python 3.11-3.14.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: d8ebdb3c-28b8-4fa1-830d-3fa7d6333d9e
Hold the adapter setup lock through singleton initialization, web-service startup, model preparation, and failure rollback. Add concurrent success/failure regressions and keep invalid-input and transport tests compatible with all CI type checkers.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: d8ebdb3c-28b8-4fa1-830d-3fa7d6333d9e
Avoid passing an unspecialized generic constructor to Executor.submit, and isolate the concurrency regressions from real HTTP client initialization.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: d8ebdb3c-28b8-4fa1-830d-3fa7d6333d9e
Normalize native token limits and response schemas, preserve required tool invocation before structured replies, expose download controls, and roll back services started during failed client setup. Expand transport and agent regressions and document public-catalog-only scope.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: d8ebdb3c-28b8-4fa1-830d-3fa7d6333d9e
The Foundry Local checks passed. The first full matrix failed in the existing declarative MCP approval/checkpoint regression and cancelled other matrix rows. GitHub requires repository-admin rights for a rerun, so trigger a fresh check run without changing unrelated code.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: d8ebdb3c-28b8-4fa1-830d-3fa7d6333d9e

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bmehta001 One material regression remains in python/packages/foundry_local/agent_framework_foundry_local/_foundry_local_client.py:219 and :328. Forwarding response_format={"type": "text"} to Foundry Local SDK 2.2.1 sets tool_choice="none", so an agent requesting ordinary text can silently skip tools it needs in both streaming and non-streaming calls. Please remove that explicit text format from the outgoing options, or otherwise preserve the caller’s automatic tool choice, and add regressions for omitted/automatic tool selection in both response modes.

Omit explicit text response formats from HTTP requests so SDK 2.2.1 does not disable tool selection. Cover omitted, string and dictionary automatic choices in streaming and non-streaming tool loops without mutating caller options.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 02674608-bd9c-4c05-a2be-223196e5bd45
@bmehta001

bmehta001 commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor Author

Eduard van Valkenburg (@eavanvalkenburg) Addressed in 9819191. Explicit response_format={"type":"text"} is now omitted from outgoing requests, preserving automatic tool selection in SDK 2.2.1 without mutating caller options or changing structured-output handling.

Expanded the HTTP tool-loop regressions for omitted, string auto, and dictionary-form automatic selection in streaming and non-streaming modes (plus required tools and disabled local invocation). They verify no text format reaches either request, exactly-once tool execution, the matching tool-result message, and the final text response. The new text cases failed before the fix.

Preserve SDK 2.2.1 and Python compatibility constraints alongside current release metadata and HTTP client lifecycle ownership.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 45b5b23f-2d2c-4482-88b3-f5bc02588ae7
@bmehta001

Copy link
Copy Markdown
Contributor Author

Thanks Eduard van Valkenburg (@eavanvalkenburg) - I have fixed the merge conflicts

Replace wall-clock-dependent background file writers with a deterministic empty first discovery poll. Keep real file collection on retry and close the sandbox registry after both tests.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: f76e369f-8596-462c-908d-396f0945bc2a
Merge microsoft/agent-framework main at 03341b1 and preserve the deterministic Hyperlight output retry tests.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: f76e369f-8596-462c-908d-396f0945bc2a
Resolve provider imports and retain the SDK-supported Python version bounds. Update the dependency floor, verified wheel lock records, and package documentation.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: ed7dcaa5-96b5-4ecb-b1b0-08b76628db58
@bmehta001 bmehta001 changed the title Python: [BREAKING] Migrate Foundry Local integration to SDK 2.2.1 Python: [BREAKING] Migrate Foundry Local integration to SDK 2.3.1 Nov 2, 2026
@bmehta001

Copy link
Copy Markdown
Contributor Author

Eduard van Valkenburg (@eavanvalkenburg) I have updated the PR again to fix merge conflicts and use Foundry Local 2.3.1

@eavanvalkenburg

Copy link
Copy Markdown
Member

bmehta001 The SDK migration makes the standard install unsatisfiable on Intel macOS. The all extra still selects Foundry Local on CPython 3.13/macOS/x86_64, but foundry-local-sdk 2.3.1 and its native dependencies publish ARM64-only macOS wheels and no source distribution. Please gate the Foundry Local dependencies by supported platform/architecture so users who do not use this integration can still install the rest of the framework on Intel Macs.

Skip native Foundry Local dependencies on Intel macOS and other unsupported architectures while retaining Python 3.11-3.14 support on published wheel targets. Keep the workspace lockfile synchronized and cover dependency marker selection.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: f8acaa59-d3f8-45c1-8ca2-2309ca8909d5
@bmehta001

bmehta001 commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor Author

Eduard van Valkenburg (@eavanvalkenburg) Addressed in d0577d4. Added matching platform/architecture markers to the core all extra and the integration SDK dependency, so Intel macOS no longer pulls Foundry Local through the standard install, and workspace installs also skip the native SDK. Updated the lockfile and installation docs.

This branch was previously deployed

1 inactive deployment
github-app-auth — d0577d4c Deployed Nov 3, 2026 by bmehta001 via add_label #26989
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking change Usage: [PRs], Target: all PRs that introduce changes that are not backward compatible documentation Usage: [Issues, PRs], Target: documentation in the code base and learn docs python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: [Bug]: Foundry Local integration is incompatible with current SDK versions

3 participants