ImportError: cannot import name 'ReasoningEffort' from mistral_common breaks Gemma 4 processor loading in transformers 5.5.x / 5.6.0.dev0
Author: Glademist
Pull request: no
Labels: name: bug

### System Info

Environment
- transformers: 5.5.1 and 5.6.0.dev0 (git main as of ~2026-04-08)
- mistral-common: 1.9.1
- Python: 3.11.15
- Platform: macOS aarch64 (Apple Silicon)
- mlx-vlm: 0.4.x

Bug description
When loading any model via AutoProcessor (tested with google/gemma-4-31b-it and mlx-community/Qwen3.5-2B-4bit), transformers unconditionally imports ReasoningEffort from mistral_common.protocol.instruct.request inside tokenization_mistral_common.py, even when the target model has no relation to Mistral.

The import succeeds at the top of the file (line ~42) only if mistral-common exposes ReasoningEffort. In version 1.9.1 it does not, causing an ImportError. The import is guarded by is_mistral_common_available(), but the symbol ReasoningEffort itself is missing from mistral_common 1.9.1, making the guard useless.

A secondary failure occurs even when patching line 42 to catch the ImportError and stub ReasoningEffort = None: line 1042 uses ReasoningEffort in a type annotation (ReasoningEffort | None = None), which raises:

    TypeError: unsupported operand type(s) for |: 'NoneType' and 'NoneType'

The annotation is inside the MistralCommonBackend class body, which is evaluated at class definition time, not lazily.

Workaround
Patch line 42 of tokenization_mistral_common.py to stub the missing symbol as a valid type:

    try:
        from mistral_common.protocol.instruct.request import (
            ChatCompletionRequest, ReasoningEffort
        )
    except ImportError:
        from mistral_common.protocol.instruct.request import ChatCompletionRequest
        from typing import Any as ReasoningEffort

This allows the class body annotation to resolve without error and has no effect on Gemma 4 inference, which never exercises the Mistral reasoning code path.

Expected behavior
Loading a non-Mistral model (Gemma 4, Qwen3) should not fail due to a missing symbol in mistral_common. The import guard should either be tightened to only run inside Mistral-specific processor code, or ReasoningEffort should be conditionally imported with a safe fallback type.

Traceback (truncated)
  File ".../transformers/tokenization_mistral_common.py", line 42, in <module>
    from mistral_common.protocol.instruct.request import ChatCompletionRequest, ReasoningEffort
ImportError: cannot import name 'ReasoningEffort' from 'mistral_common.protocol.instruct.request'

### Who can help?

_No response_

### Information

- [ ] The official example scripts
- [ ] My own modified scripts

### Tasks

- [ ] An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...)
- [ ] My own task or dataset (give details below)

### Reproduction

fresh sourced enviroment
pip install mlx-lm mlx-vlm
mlx_vlm.generate --model mlx-community/gemma-4-31b-it-4bit --kv-bits 8 --kv-quant-scheme turboquant --enable-thinking --thinking-budget 800 --max-tokens 3000 --prompt "I have a dirty car. A car wash is 100 meters away. Do i drive there or walk if i want to wash my car?"


### Expected behavior

The model should run, however it crashes due to the ReasoningEffort failure 

Comments:
This is the problem of mistral-common, try pip install mistral-common==1.10.0

Looking into this — the unconditional import of ReasoningEffort from mistral_common breaks when users have an older version installed. Planning a try/except guard.

This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the [contributing guidelines](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md) are likely to be ignored.

我去掉model_type 成功启动了

This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the [contributing guidelines](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md) are likely to be ignored.