Skip to content

Python: fix(mistral): report an injected SDK client's own endpoint - #10044

Closed
Fish (wxhking) wants to merge 1 commit into
microsoft:mainfrom
wxhking:fix/mistral-injected-client-endpoint
Closed

Fish (wxhking) wants to merge 1 commit into
microsoft:mainfrom
wxhking:fix/mistral-injected-client-endpoint

Conversation

@wxhking

Copy link
Copy Markdown

Fixes #9965

Summary

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 service_url() and telemetry metadata 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, the settings loader now receives no server_url input at all, and server_url is read off the client after construction — so service_url() always reports the endpoint the requests actually go to.

  • owned-client construction keeps the existing precedence (explicit server_url → MISTRAL_SERVER_URL → SDK default)
  • the API-key requirement stays keyed on whether a client / http_client is injected
  • model resolution and http_client base-URL reporting are unchanged
  • docstrings state the injected-client precedence

Evidence

  • new tests/mistral/test_mistral_injected_client_endpoint.py: with MISTRAL_SERVER_URL=https://env.example, an SDK client built for https://client.example is reported by service_url() on both the chat and embedding wrappers; the no-client path still honors the env URL; an explicit server_url with an owned client still wins; an injected client requires no MISTRAL_API_KEY — 5 cases
  • pytest tests/mistral — 178 passed, 16 skipped, no new failures
  • ruff check / format clean on all three changed files

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
Copilot AI balanced review requested due to automatic review settings November 3, 2026 14:34
@agent-framework-automation agent-framework-automation Bot added the python Usage: [Issues, PRs], Target: Python label Nov 3, 2026
@github-actions github-actions Bot changed the title fix(mistral): report an injected SDK client's own endpoint Python: fix(mistral): report an injected SDK client's own endpoint Nov 3, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 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,
@eavanvalkenburg

Copy link
Copy Markdown
Member

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.

@wxhking

Copy link
Copy Markdown
Author

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.

This branch was previously deployed

1 inactive deployment
github-app-auth — dc76a8a3 Deployed Nov 3, 2026 by wxhking via add_label #26967
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: [Bug]: Mistral environment endpoint overrides injected-client service metadata

3 participants