Skip to content

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

Description

Observed Behavior

Mistral chat and embedding constructors load MISTRAL_SERVER_URL before inspecting an injected mistralai.client.Mistral. When the environment contains a different URL, the wrapper keeps that environment value in self.server_url and service_url(), while requests still use the endpoint configured on the injected SDK client.

This produces inconsistent configuration and incorrect telemetry metadata.

Affected files:

  • python/packages/mistral/agent_framework_mistral/_chat_client.py
  • python/packages/mistral/agent_framework_mistral/_embedding_client.py

Expected Behavior

For an injected Mistral SDK client, the actual client endpoint should take precedence over explicit or environment client-construction settings. API key and server URL settings should only be resolved when Agent Framework constructs the SDK client. Wrapper-level model resolution can remain independent.

Steps to Reproduce

  1. Set MISTRAL_SERVER_URL=https://env.example.
  2. Create a Mistral SDK client for https://client.example.
  3. Inject it into a Mistral chat or embedding client.
  4. Observe that service_url() reports the environment endpoint instead of the client's endpoint.

Minimal Reproduction

import os
from mistralai.client import Mistral
from agent_framework_mistral import RawMistralChatClient

os.environ["MISTRAL_SERVER_URL"] = "https://env.example"
sdk = Mistral(api_key="dummy", server_url="https://client.example")
client = RawMistralChatClient(client=sdk, model="mistral-test")

print(client.service_url())
print(sdk.sdk_configuration.get_server_details()[0])

Error Messages and Stack Traces

service_url(): https://env.example
SDK endpoint:  https://client.example

Package Versions

agent-framework-mistral: 1.0.0b261030; main at 93c346f

Python Version

Python 3.13.1

Operating System

macOS

Regression

Unknown

Additional Context

Compatibility impact: beta wrappers would report the injected client's endpoint instead of ambient configuration. Requests already use the injected client, so this aligns metadata with actual behavior.

Focused acceptance tests:

  • Chat and embedding service_url() use the injected SDK endpoint despite MISTRAL_SERVER_URL.
  • API key/server URL settings are not loaded for an injected SDK client.
  • Explicit model and model environment fallback remain unchanged.
  • Injected SDK and HTTP clients remain open after wrapper close.
  • Owned-client initialization keeps existing precedence.

AI assistance: I used an AI coding assistant to audit and reproduce the behavior.

Acknowledgements

  • I searched existing issues and did not find a duplicate.
  • I personally verified this behavior and the reproduction details are authentic.

Metadata

Metadata

Labels

pythonUsage: [Issues, PRs], Target: Pythonready-for-implementationMaintainers agree the problem and direction are ready for implementation.

Type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions