Repository navigation
Python: fix(mistral): report an injected SDK client's own endpoint - #10044
Fish (wxhking) wants to merge 1 commit into
Conversation
The Mistral chat and embedding wrappers resolved MISTRAL_SERVER_URL (or the explicit server_url) before inspecting an injected mistralai.client.Mistral, then kept that ambient value in self.server_url / service_url(). Requests still went to the endpoint configured on the injected client, so telemetry metadata and service_url() disagreed with actual behavior: with MISTRAL_SERVER_URL=https://env.example and an SDK client built for https://client.example, service_url() reported env.example. For an injected SDK client, settings now receive no server_url input at all (the URL is read off the client after construction), so service_url() always reports the endpoint the requests actually go to. Owned-client construction, explicit overrides, model resolution and the API-key requirement are unchanged. Fixes microsoft#9965
There was a problem hiding this comment.
🟡 Changes recommended
Both Mistral clients still resolve credential and endpoint settings when SDK clients are injected, violating the requirement to bypass those settings.
1 open issue
What changed in this PR
This PR addresses #9965 by aligning Mistral chat and embedding endpoint metadata with the injected SDK client, rather than ambient configuration.
Changes:
- Report injected SDK endpoints while preserving owned-client URL precedence.
- Document injected-client endpoint precedence.
- Add five regression tests covering endpoint reporting and injected-client credential requirements.
| File | Description |
|---|---|
python/packages/mistral/tests/mistral/test_mistral_injected_client_endpoint.py |
Adds endpoint-precedence and credential-requirement tests. |
python/packages/mistral/agent_framework_mistral/_embedding_client.py |
Reports the injected embedding client's endpoint and documents precedence. |
python/packages/mistral/agent_framework_mistral/_chat_client.py |
Reports the injected chat client's endpoint and documents precedence. |
Review effort: Balanced
| api_key=api_key, | ||
| chat_model=model, | ||
| server_url=server_url, | ||
| server_url=None if client is not None else server_url, |
|
Thanks Fish (@wxhking) for the contribution. This is a duplicate of the older #9968, which addresses the same #9965 endpoint-reporting bug in the same Mistral client paths. To keep review focused on one implementation, I’m closing this newer PR. |
|
Thanks Eduard van Valkenburg (@eavanvalkenburg) for the quick coordination, and apologies for the duplicate — I had scanned open PRs right before opening this and missed #9968. No hard feelings here; the same bug is being handled in #9968, and I'd rather have one focused implementation reviewed. Happy to help test or review #9968 if useful. |

Fixes #9965
Summary
The Mistral chat and embedding wrappers resolved
MISTRAL_SERVER_URL(or the explicitserver_url) before inspecting an injectedmistralai.client.Mistral, then kept that ambient value inself.server_url/service_url(). Requests still went to the endpoint configured on the injected client, soservice_url()and telemetry metadata disagreed with actual behavior: withMISTRAL_SERVER_URL=https://env.exampleand an SDK client built forhttps://client.example,service_url()reportedenv.example.For an injected SDK client, the settings loader now receives no
server_urlinput at all, andserver_urlis read off the client after construction — soservice_url()always reports the endpoint the requests actually go to.server_url→MISTRAL_SERVER_URL→ SDK default)http_clientis injectedhttp_clientbase-URL reporting are unchangedEvidence
tests/mistral/test_mistral_injected_client_endpoint.py: withMISTRAL_SERVER_URL=https://env.example, an SDK client built forhttps://client.exampleis reported byservice_url()on both the chat and embedding wrappers; the no-client path still honors the env URL; an explicitserver_urlwith an owned client still wins; an injected client requires noMISTRAL_API_KEY— 5 casespytest tests/mistral— 178 passed, 16 skipped, no new failures