Skip to content

Add UnavailableReason for MLXLanguageModel#138

Merged
mattt merged 4 commits intomainfrom
mattt/mlx-sometimes-not-always-never
Feb 24, 2026
Merged

Add UnavailableReason for MLXLanguageModel#138
mattt merged 4 commits intomainfrom
mattt/mlx-sometimes-not-always-never

Conversation

@mattt
Copy link
Owner

@mattt mattt commented Feb 24, 2026

Resolves #137

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds an explicit UnavailableReason for MLXLanguageModel so it can report whether a model is actually loaded (or failed to load), addressing Issue #137.

Changes:

  • Introduces MLXLanguageModel.UnavailableReason with notLoaded / failedToLoad(String) and a custom availability implementation.
  • Extends the shared MLX model context cache to track and surface the most recent load failure per model key.
  • Adds tests verifying availability transitions for both a nonexistent model and a successful load.

Reviewed changes

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

File Description
Tests/AnyLanguageModelTests/MLXLanguageModelTests.swift Adds test cases asserting .notLoaded → .failedToLoad on load failure and .notLoaded → .available on successful load.
Sources/AnyLanguageModel/Models/MLXLanguageModel.swift Implements real availability reporting by tracking cached contexts and last load failures in the shared cache.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@mattt mattt merged commit 7b311b1 into main Feb 24, 2026
7 checks passed
@mattt mattt deleted the mattt/mlx-sometimes-not-always-never branch February 24, 2026 11:31
@noorbhatia
Copy link
Contributor

Thanks for the quick resolution @mattt !!!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MLXLanguageModel availability always returns .available even when model is not loaded

3 participants