AI & Agent Dev Bug Sandbox logo
AI & Agent Dev Bug Sandbox
Back to Radar

ProviderStrategy Passes 'Strict' Parameter To Mistral AI Causing 422 Error In Structured Outputs

When using create_agent with ProviderStrategy and a Pydantic model for Mistral AI, the 'strict' parameter is incorrectly sent to the Mistral API, which does not support it, resulting in a 422 Unprocessable Entity error. This prevents structured output with Mistral models.

highConfidence 92%LangchainAffected Vlangchain-Mistralai==1.1.2

Origin Analysis

The LangChain ProviderStrategy unconditionally sets 'strict': True when generating a JSON schema response format, assuming OpenAI-style structured outputs. The langchain-mistralai integration does not filter out this parameter before sending the request to the Mistral API, leading to an extra forbidden parameter error.
1. Install langchain, langchain-mistralai, and dependencies. 2. Define a Pydantic model with fields. 3. Create an agent with create_agent('mistral-medium-3-5', response_format=ProviderStrategy(MeetingAction)). 4. Invoke the agent with a user message. 5. Observe 422 error with 'Extra inputs are not permitted' for 'strict'.

Fixing Code Block

Edge Case Audit

This is a hotfix that modifies the API client on a specific instance. It may not be thread-safe if the client is shared across threads and the original method is reassigned. It also assumes Mistral API will not require 'strict' in the future. For a permanent fix, update langchain-mistralai to ignore 'strict' or update ProviderStrategy to allow per-provider strict configuration. Rollback: restore the original create method (e.g., chat_model.client.chat.completions.create = original_create).

Ecosystem Topology