Repository navigation
Conversation
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
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
There was a problem hiding this comment.
🟡 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.
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
Keep dependency floors unchanged and cover raw schemas, schema references, and named envelopes for streaming and non-streaming requests. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 8cc02580-c3c4-41aa-a2f6-f06f37c1cb62
|
Eduard van Valkenburg (@eavanvalkenburg) Thanks for the comment. I have updated the PR to support raw JSON schema as well. |
Use the released SDK with its pinned ORT 1.31.0 and GenAI 0.18.0 runtimes while retaining the existing SDK compatibility range. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 90bff81a-94dd-4dc2-aa6e-3c500fd5232b
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 294da005-b292-4823-9b62-763305e6b0c1
Preserve upstream dependency bumps and DuckDB Python 3.15 coverage while retaining Foundry Local's Python 3.11-3.14 support window. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 43f82116-141b-402e-877a-ce0ea8ef6dcc
Align ONNX Runtime's dependency with the NumPy 2.5.4 package already locked by main. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 581ec03f-0146-4693-8378-a80600bb504c
Eduard van Valkenburg (eavanvalkenburg)
left a comment
There was a problem hiding this comment.
bmehta001 Please address the inline automatic-tool-selection finding before merge.
Reject unsupported HTTP decoder controls and automatic tool selection with structured output. Preserve required-tool final responses and restore consistent function-layer typing. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: f6deb902-ceaf-4a1d-bed1-f10020bda2e7
|
Eduard van Valkenburg (@eavanvalkenburg) Thanks; have addressed. I restored the original function-layer generic, unsupported decoder controls are explicitly rejected, and automatic tool selection with structured output is explicitly rejected while required/named tool flows are preserved. The earlier raw-schema compatibility fix and its agent-framework-openai 1.6.0-style regression coverage remain in place; no dependency-floor changes were made. One existing check limitation remains: Zuban reports the same two SupportsChatGetResponse.client errors at test_foundry_local_client.py:77-78 on both the prior branch head and this commit. |
Eduard van Valkenburg (eavanvalkenburg)
left a comment
There was a problem hiding this comment.
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
|
Eduard van Valkenburg (@eavanvalkenburg) Addressed in 9819191. Explicit Expanded the HTTP tool-loop regressions for omitted, string |



Motivation & Context
The Foundry Local integration still uses SDK 0.5.1. This updates it to work with SDK 2.2.1.
Description & Review Guide
prepare_model=Falsestill loads the configured model on the first request, including streaming; manual loading is not required.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
AI assistance details: GitHub Copilot helped with the code, tests, documentation, and this description.
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.