Skip to content

fix(mistral): support both the 1.x and the 2.x+ client layouts - #12

Merged
Jeomon merged 1 commit into
Jeomon:mainfrom
hussainbiedouh:fix/mistral-client-layout-compat
Oct 27, 2026
Merged

Jeomon merged 1 commit into
Jeomon:mainfrom
hussainbiedouh:fix/mistral-client-layout-compat

Conversation

@hussainbiedouh

@hussainbiedouh hussainbiedouh commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

The two generations of the mistralai client have mutually exclusive import paths for the same class:

import 1.9.11 3.3.0
from mistralai import Mistral ok error
from mistralai.client import Mistral error ok
from mistralai.sdk import Mistral ok error

mistralai 1.9.11 keeps a deprecated stub in mistralai.client and exports the client from the top level. 2.x dropped the top level package and moved the client into mistralai.client.

main currently uses the 2.x path, which breaks against the version pinned in uv.lock and fails the test job:

ImportError: cannot import name 'Mistral' from 'mistralai.client'
  windows_use/providers/mistral/llm.py:7: in <module>
    from mistralai.client import Mistral

The released 0.8.1 uses the 1.x path, which breaks for anyone who installs a current mistralai instead of the pinned one.

This tries the new location first and falls back to the old one, so the provider imports on both.

Because windows_use/providers/__init__.py imports every provider eagerly, a broken import here takes down import windows_use completely - hence the regression test.

Testing

  • uv run pytest tests/unit/ -v --tb=short - 109 passed, 5 skipped (was 7 collection errors)
  • import windows_use verified against mistralai 1.9.11 and 3.3.0

Related

This is the code half of #11. The other half is a release: the published 0.8.1 still carries the 1.x import, so pip install windows-use stays broken until a new version is cut.

The two generations of the mistralai client have mutually exclusive import
paths for the same class:

| import                             | 1.9.11 | 3.3.0 |
| ---------------------------------- | ------ | ----- |
| `from mistralai import Mistral`    | ok     | error |
| `from mistralai.client import ...` | error  | ok    |
| `from mistralai.sdk import ...`    | ok     | error |

1.9.11 keeps a deprecated stub in `mistralai.client` and exports the client
from the top level. 2.x dropped the top level package and moved the client
into `mistralai.client`.

main used the 2.x path, which breaks against the version pinned in uv.lock
and fails the test job with "cannot import name 'Mistral' from
'mistralai.client'". The released 0.8.1 used the 1.x path, which breaks for
anyone who installs a current mistralai.

Try the new location first and fall back to the old one, so the provider
works on both.
@Jeomon
Jeomon merged commit 038440d into Jeomon:main Oct 27, 2026
1 check passed
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.

2 participants