-
Notifications
You must be signed in to change notification settings - Fork 184
[Fix][Refactor]Migrate FoundryLocal integration to official Microsoft.AI.Foundry.Local.WinML SDK #532
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
weiyuanyue
wants to merge
20
commits into
main
Choose a base branch
from
milly/flfixonly
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…l SDK's ExcludeExtraLibs pattern
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR addresses a production-breaking bug that blocked model downloads from FoundryLocal in AIDG after upgrading to Foundry Local v0.8.x+.
We restore functionality and improve robustness by migrating from custom HTTP calls to the official Microsoft.AI.Foundry.Local.WinML SDK.
Bottom line: Users can again download and prepare models reliably, and the system is significantly more resilient to future upstream API changes.
Background
In July, Foundry Local changed the string format of a critical Name field in its HTTP API.
The change was handled internally by Foundry Local but not communicated externally, causing silent incompatibility with AIDG’s direct HTTP API calls.
After upgrading to v0.8.x, AIDG’s download workflow broke: calls failed and downstream features relying on those models were effectively blocked.
Impact: it disrupts user flows (FoundryModel download → prepare → chat/inference). Leaving this unfixed would stall developer productivity, inflate support tickets, and erode trust in AIDG’s stability.
Decision
To eliminate this class of failures and avoid future format drift, we migrate to the official SDK:
Changes
Architecture Improvements
FoundryLocalManagerAPIfoundryexecutable in favor of native SDK integrationCode Simplification
FoundryServiceManager- API-based service orchestrationFoundryJsonContext- custom JSON serialization contextsUtils- process execution wrappersFoundryCatalogModel: Reduced from 100+ lines to 21 lines by leveraging SDK typesEnhanced Functionality
EnsureModelReadyAsync(): Explicit model preparation API to prevent deadlocks when accessing IChatClientTechnical Details
Runtimeproperties to prevent UI crashesDependencies
Microsoft.AI.Foundry.Local.WinMLv0.8.2.1Microsoft.ML.OnnxRuntimeGenAIpackages from v0.10.1 → v0.11.4Testing
EnsureModelReadyAsync()IDisposableAnalyzers Build Errors
This PR introduces the Microsoft.AI.Foundry.Local.WinML(0.8.2.1) package as a new dependency. This package includes IDisposableAnalyzers (4.0.8) as a transitive dependency, which is a code analyzer that enforces proper IDisposable pattern usage.
Since the main branch does not have this package, it doesn't have the IDisposableAnalyzers, and therefore doesn't encounter these errors. When building this branch, the analyzer runs automatically and reports 237+ violations across the codebase related to improper disposal of IDisposable objects.
Temporary Solution
To unblock the build while keeping the scope of this PR focused on Foundry Local integration, these analyzer warnings have been temporarily suppressed:
Next Steps
A separate PR should be created to properly address these IDisposable violations by: