feat(mistral): migrate LLM to Conversations API with provider tools support#5527
Merged
tinalenguyen merged 6 commits intolivekit:mainfrom Apr 22, 2026
Merged
Conversation
tinalenguyen
approved these changes
Apr 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
enabling support for Mistral's built-in provider tools: Web Search, Code Interpreter, and Document Library
MistralToolbase class withWebSearch,CodeInterpreter, andDocumentLibraryprovider tool definitionstop_p,presence_penalty,frequency_penalty,random_seed,tool_choice)pcmtomp3Details
Conversations API migration
The Conversations API is stateful — the server retains conversation history across calls. This enables:
start_stream_async()sends the full context, model, instructions, and toolsappend_stream_async()sends only new client-originated entries (function.result,message.input), avoiding redundant re-transmission of the full historyContext diffing uses
ChatContext.is_equivalent()(following the OpenAI Responses API pattern) to detect whether the new context extends the previous one. If it diverges, the conversation is reset with a freshstart_stream_async().A pending tool call verification safeguard ensures all function calls from the previous response have results before attempting to append.
Streaming event handling
The Conversations API uses typed SSE events instead of choice deltas.
ResponseStartedEventconversation_idfor stateful trackingMessageOutputEventChatChunkwith text contentFunctionCallEvent_PendingFunctionCallbuffer, flushed as completeFunctionToolCallon next non-function event (since arguments are sent delta-wise incrementally)ToolExecution{Started,Delta,Done}EventResponseDoneEventResponseErrorEventAPIStatusErrorProvider format converter
Replaces the old
to_chat_ctx()(which delegated to OpenAI format) withto_conversations_ctx()that produces Mistral's flat entry format:instructionsstring (returned viaMistralFormatData){"type": "message.input", ...}{"type": "message.output", ...}{"type": "function.call", ...}{"type": "function.result", ...}LLM completion parameters
The LLM constructor and
update_options()now accept the full set ofCompletionArgsparameters supported by the Conversations API:temperature,top_p,max_completion_tokens,presence_penalty,frequency_penalty,random_seed, andtool_choice.TTS default response format
Switches the default TTS response format from
pcmback tomp3, since it is the most reliable default for most setups.Usage