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

Mistral Integration Does Not Properly Handle Retries And Concurrency Limits

ChatMistralAI fails to enforce max_concurrent_requests for async calls and applies retry logic without filtering for transient errors, leading to excessive retries and uncontrolled parallel requests that may trigger rate limits.

highConfidence 85%Langchain-MistralaiEmbeddingsVector StoresAgentsAffected V1.1.2

Origin Analysis

The ChatMistralAI class does not use an asyncio.Semaphore to limit concurrent async invocations, and its retry decorator lacks a retry_if_exception condition, causing all exceptions (including permanent client errors like 400) to be retried.
Instantiate ChatMistralAI(max_concurrent_requests=2), define an async function that awaits llm.ainvoke('Hello'), then run 5 such calls concurrently using asyncio.gather. Observe that more than 2 requests are in flight simultaneously, and that errors like 400 Bad Request are retried multiple times instead of failing immediately.

Fixing Code Block

Edge Case Audit

The introduced semaphore may cause request queuing under high load, increasing latency; ensure the semaphore is created within an async context to avoid binding issues. The retry filter must be applied to both sync and async paths to maintain consistent behavior. If the underlying Mistral client changes attribute names, the fix must be adjusted accordingly. Rollback advice: revert to the previous version or remove the semaphore and retry filter if unexpected blocking or retry suppression occurs.

Ecosystem Topology

Agent Frameworks

LangChain, LlamaIndex, and Pydantic

  1. highProperty graph relation keys collide when entity IDs or labels contain underscores
  2. highCodeActAgent drops assistant tool-call metadata during handoff, leaving an orphan tool response
  3. high[Bug]: HierarchicalNodeParser async methods return the documents unsplit
  4. highLLM.predict_and_call fails with ValidationError for non-function-calling models when react_chat_formatter is omitted
  5. highAnthropic streaming server-tool input_json_delta overwrites completed client tool_use arguments due to stale cur_tool_call state